@shivaedev/server 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +323 -2
- package/dist/AppHostFactory.d.ts +15 -0
- package/dist/AppHostFactory.d.ts.map +1 -0
- package/dist/AppHostFactory.js +2 -0
- package/dist/AppHostFactory.js.map +1 -0
- package/dist/AppHostInput.d.ts +13 -0
- package/dist/AppHostInput.d.ts.map +1 -0
- package/dist/AppHostInput.js +2 -0
- package/dist/AppHostInput.js.map +1 -0
- package/dist/MigrationOptions.d.ts +15 -0
- package/dist/MigrationOptions.d.ts.map +1 -0
- package/dist/MigrationOptions.js +2 -0
- package/dist/MigrationOptions.js.map +1 -0
- package/dist/RedactionPolicy.d.ts +4 -0
- package/dist/RedactionPolicy.d.ts.map +1 -0
- package/dist/RedactionPolicy.js +4 -0
- package/dist/RedactionPolicy.js.map +1 -0
- package/dist/appHost.d.ts +47 -0
- package/dist/appHost.d.ts.map +1 -0
- package/dist/appHost.js +17 -0
- package/dist/appHost.js.map +1 -0
- package/dist/appHostHttp.d.ts +88 -0
- package/dist/appHostHttp.d.ts.map +1 -0
- package/dist/appHostHttp.js +67 -0
- package/dist/appHostHttp.js.map +1 -0
- package/dist/boundedRpcRequest.d.ts +3 -0
- package/dist/boundedRpcRequest.d.ts.map +1 -0
- package/dist/boundedRpcRequest.js +22 -0
- package/dist/boundedRpcRequest.js.map +1 -0
- package/dist/databaseAddress.d.ts +4 -0
- package/dist/databaseAddress.d.ts.map +1 -0
- package/dist/databaseAddress.js +25 -0
- package/dist/databaseAddress.js.map +1 -0
- package/dist/databaseLayer.d.ts +14 -0
- package/dist/databaseLayer.d.ts.map +1 -0
- package/dist/databaseLayer.js +100 -0
- package/dist/databaseLayer.js.map +1 -0
- package/dist/development.d.ts +10 -0
- package/dist/development.d.ts.map +1 -0
- package/dist/development.js +20 -0
- package/dist/development.js.map +1 -0
- package/dist/healthRoute.d.ts +3 -0
- package/dist/healthRoute.d.ts.map +1 -0
- package/dist/healthRoute.js +18 -0
- package/dist/healthRoute.js.map +1 -0
- package/dist/hostChanges.d.ts +7 -0
- package/dist/hostChanges.d.ts.map +1 -0
- package/dist/hostChanges.js +25 -0
- package/dist/hostChanges.js.map +1 -0
- package/dist/hostOptions.d.ts +34 -0
- package/dist/hostOptions.d.ts.map +1 -0
- package/dist/hostOptions.js +2 -0
- package/dist/hostOptions.js.map +1 -0
- package/dist/hostTransport.d.ts +16 -0
- package/dist/hostTransport.d.ts.map +1 -0
- package/dist/hostTransport.js +16 -0
- package/dist/hostTransport.js.map +1 -0
- package/dist/nativeClientOrigins.d.ts +4 -0
- package/dist/nativeClientOrigins.d.ts.map +1 -0
- package/dist/nativeClientOrigins.js +38 -0
- package/dist/nativeClientOrigins.js.map +1 -0
- package/dist/node-http/subscriptionSignal.d.ts +12 -0
- package/dist/node-http/subscriptionSignal.d.ts.map +1 -0
- package/dist/node-http/subscriptionSignal.js +55 -0
- package/dist/node-http/subscriptionSignal.js.map +1 -0
- package/dist/otlpHttpClient.d.ts +4 -0
- package/dist/otlpHttpClient.d.ts.map +1 -0
- package/dist/otlpHttpClient.js +36 -0
- package/dist/otlpHttpClient.js.map +1 -0
- package/dist/otlpTracing.d.ts +3 -0
- package/dist/otlpTracing.d.ts.map +1 -0
- package/dist/otlpTracing.js +35 -0
- package/dist/otlpTracing.js.map +1 -0
- package/dist/redactOtlpUrl.d.ts +2 -0
- package/dist/redactOtlpUrl.d.ts.map +1 -0
- package/dist/redactOtlpUrl.js +41 -0
- package/dist/redactOtlpUrl.js.map +1 -0
- package/dist/redactingDiagnostics.d.ts +5 -0
- package/dist/redactingDiagnostics.d.ts.map +1 -0
- package/dist/redactingDiagnostics.js +25 -0
- package/dist/redactingDiagnostics.js.map +1 -0
- package/dist/redactingRpcSerialization.d.ts +4 -0
- package/dist/redactingRpcSerialization.d.ts.map +1 -0
- package/dist/redactingRpcSerialization.js +74 -0
- package/dist/redactingRpcSerialization.js.map +1 -0
- package/dist/redactingTracer.d.ts +4 -0
- package/dist/redactingTracer.d.ts.map +1 -0
- package/dist/redactingTracer.js +32 -0
- package/dist/redactingTracer.js.map +1 -0
- package/dist/rpc-server/publicConfigLayer.d.ts +4 -0
- package/dist/rpc-server/publicConfigLayer.d.ts.map +1 -0
- package/dist/rpc-server/publicConfigLayer.js +9 -0
- package/dist/rpc-server/publicConfigLayer.js.map +1 -0
- package/dist/runtime/makePlatform.d.ts +4 -0
- package/dist/runtime/makePlatform.d.ts.map +1 -0
- package/dist/runtime/makePlatform.js +65 -0
- package/dist/runtime/makePlatform.js.map +1 -0
- package/dist/runtime/types.d.ts +19 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/safeOtlpSerialization.d.ts +6 -0
- package/dist/safeOtlpSerialization.d.ts.map +1 -0
- package/dist/safeOtlpSerialization.js +67 -0
- package/dist/safeOtlpSerialization.js.map +1 -0
- package/dist/schemaSensitiveKeys.d.ts +5 -0
- package/dist/schemaSensitiveKeys.d.ts.map +1 -0
- package/dist/schemaSensitiveKeys.js +143 -0
- package/dist/schemaSensitiveKeys.js.map +1 -0
- package/dist/setupDatabases.d.ts +3 -0
- package/dist/setupDatabases.d.ts.map +1 -0
- package/dist/setupDatabases.js +12 -0
- package/dist/setupDatabases.js.map +1 -0
- package/dist/tracedGroup.d.ts +4 -0
- package/dist/tracedGroup.d.ts.map +1 -0
- package/dist/tracedGroup.js +13 -0
- package/dist/tracedGroup.js.map +1 -0
- package/package.json +110 -3
- package/src/AppHostFactory.ts +121 -0
- package/src/AppHostInput.ts +74 -0
- package/src/MigrationOptions.ts +15 -0
- package/src/RedactionPolicy.ts +4 -0
- package/src/appHost.ts +117 -0
- package/src/appHostHttp.ts +147 -0
- package/src/boundedRpcRequest.ts +28 -0
- package/src/databaseAddress.ts +25 -0
- package/src/databaseLayer.ts +127 -0
- package/src/development.ts +34 -0
- package/src/healthRoute.ts +27 -0
- package/src/hostChanges.ts +34 -0
- package/src/hostOptions.ts +30 -0
- package/src/hostTransport.ts +26 -0
- package/src/nativeClientOrigins.ts +44 -0
- package/src/node-http/subscriptionSignal.ts +64 -0
- package/src/otlpHttpClient.ts +54 -0
- package/src/otlpTracing.ts +61 -0
- package/src/redactOtlpUrl.ts +48 -0
- package/src/redactingDiagnostics.ts +33 -0
- package/src/redactingRpcSerialization.ts +85 -0
- package/src/redactingTracer.ts +37 -0
- package/src/rpc-server/publicConfigLayer.ts +12 -0
- package/src/runtime/makePlatform.ts +75 -0
- package/src/runtime/types.ts +24 -0
- package/src/safeOtlpSerialization.ts +73 -0
- package/src/schemaSensitiveKeys.ts +148 -0
- package/src/setupDatabases.ts +12 -0
- package/src/tracedGroup.ts +14 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { NodeServices } from "@effect/platform-node";
|
|
2
|
+
import { Config, Effect, Layer } from "effect";
|
|
3
|
+
import { HttpRouter } from "effect/http";
|
|
4
|
+
import { type Rpc, RpcSerialization } from "effect/rpc";
|
|
5
|
+
import type { RequestTracing } from "@shivaedev/identity/middleware.ts";
|
|
6
|
+
import { type SessionShape } from "@shivaedev/identity/server/session.ts";
|
|
7
|
+
import type { AppChanges, AppHttpHostOptions } from "#appHost.ts";
|
|
8
|
+
import type { databaseLayer } from "#databaseLayer.ts";
|
|
9
|
+
import type { HostOptions, HostPolicy } from "#hostOptions.ts";
|
|
10
|
+
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
11
|
+
export declare function appHostHttp<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession extends SessionShape>(options: HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostPolicy<TSession>, changesService: typeof AppChanges): Layer.Layer<TServices | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices, TServiceError | Config.ConfigError | import("effect/PlatformError").PlatformError | import("effect/http/HttpServerError").ServeError | HttpRouter.Request.Without<THandlerError>, Exclude<Exclude<Exclude<Exclude<Exclude<TServiceRequirements, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/FileSystem").FileSystem, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/http/HttpPlatform").HttpPlatform, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/http/HttpServer").HttpServer, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/Path").Path, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
12
|
+
readonly _tag: `${string}.$changes`;
|
|
13
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
14
|
+
readonly _tag: `${string}.$changes`;
|
|
15
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
16
|
+
readonly _tag: `${string}.$changes`;
|
|
17
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
18
|
+
readonly _tag: `${string}.$changes`;
|
|
19
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
20
|
+
readonly _tag: `${string}.$changes`;
|
|
21
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
22
|
+
readonly _tag: `${string}.$changes`;
|
|
23
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
24
|
+
readonly _tag: `${string}.$changes`;
|
|
25
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
26
|
+
readonly _tag: `${string}.$changes`;
|
|
27
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
28
|
+
readonly _tag: `${string}.$changes`;
|
|
29
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
30
|
+
readonly _tag: `${string}.$changes`;
|
|
31
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
32
|
+
readonly _tag: `${string}.$changes`;
|
|
33
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
34
|
+
readonly _tag: `${string}.$changes`;
|
|
35
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>>;
|
|
36
|
+
export declare function migratedHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape>(options: HostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostPolicy<TSession> & {
|
|
37
|
+
readonly migrations: MigrationOptions<TMigrations>;
|
|
38
|
+
}, database: ReturnType<typeof databaseLayer<TMigrations>>, changesService: typeof AppChanges): Layer.Layer<TServices | AppChanges | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient | NodeServices.NodeServices, TServiceError | Config.ConfigError | import("effect/sql/Migrator").MigrationError | import("effect/PlatformError").PlatformError | import("effect/http/HttpServerError").ServeError | import("effect/sql/SqlError").SqlError | HttpRouter.Request.Without<THandlerError>, Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<TServiceRequirements, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/FileSystem").FileSystem, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/http/HttpPlatform").HttpPlatform, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/http/HttpServer").HttpServer, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/Path").Path, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<TMigrations, import("effect/Scope").Scope>, import("@effect/sql-pg/PgClient").PgClient | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
39
|
+
readonly _tag: `${string}.$changes`;
|
|
40
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
41
|
+
readonly _tag: `${string}.$changes`;
|
|
42
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
43
|
+
readonly _tag: `${string}.$changes`;
|
|
44
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
45
|
+
readonly _tag: `${string}.$changes`;
|
|
46
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
47
|
+
readonly _tag: `${string}.$changes`;
|
|
48
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
49
|
+
readonly _tag: `${string}.$changes`;
|
|
50
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
51
|
+
readonly _tag: `${string}.$changes`;
|
|
52
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
53
|
+
readonly _tag: `${string}.$changes`;
|
|
54
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
55
|
+
readonly _tag: `${string}.$changes`;
|
|
56
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
57
|
+
readonly _tag: `${string}.$changes`;
|
|
58
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
59
|
+
readonly _tag: `${string}.$changes`;
|
|
60
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
61
|
+
readonly _tag: `${string}.$changes`;
|
|
62
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices | AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>>;
|
|
63
|
+
export declare function deferredHost<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TSession extends SessionShape, TApplicationError, TApplicationRequirements>(application: Effect.Effect<AppHttpHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TSession>, TApplicationError, TApplicationRequirements>, database: ReturnType<typeof databaseLayer<TMigrations>>, changesService: typeof AppChanges): Layer.Layer<TServices | AppChanges | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient | NodeServices.NodeServices, TApplicationError | TServiceError | Config.ConfigError | import("effect/sql/Migrator").MigrationError | import("effect/PlatformError").PlatformError | import("effect/http/HttpServerError").ServeError | import("effect/sql/SqlError").SqlError | HttpRouter.Request.Without<THandlerError>, Exclude<Exclude<TApplicationRequirements, import("effect/Scope").Scope>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<TMigrations, import("effect/Scope").Scope>, import("@effect/sql-pg/PgClient").PgClient | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<TServiceRequirements, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/FileSystem").FileSystem, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/http/HttpPlatform").HttpPlatform, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/http/HttpServer").HttpServer, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<import("effect/Path").Path, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
64
|
+
readonly _tag: `${string}.$changes`;
|
|
65
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
66
|
+
readonly _tag: `${string}.$changes`;
|
|
67
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
68
|
+
readonly _tag: `${string}.$changes`;
|
|
69
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"GlobalRequires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
70
|
+
readonly _tag: `${string}.$changes`;
|
|
71
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
72
|
+
readonly _tag: `${string}.$changes`;
|
|
73
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
74
|
+
readonly _tag: `${string}.$changes`;
|
|
75
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
76
|
+
readonly _tag: `${string}.$changes`;
|
|
77
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Only<"Requires", Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
78
|
+
readonly _tag: `${string}.$changes`;
|
|
79
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.GlobalProvided>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<THandlerRequirements, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<HttpRouter.HttpRouter, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
80
|
+
readonly _tag: `${string}.$changes`;
|
|
81
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<RpcSerialization.RpcSerialization, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
82
|
+
readonly _tag: `${string}.$changes`;
|
|
83
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ServicesServer<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
84
|
+
readonly _tag: `${string}.$changes`;
|
|
85
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient> | Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<Exclude<HttpRouter.Request.Without<Exclude<Exclude<Exclude<Exclude<Exclude<Rpc.ToHandler<Rpc.AddMiddleware<TRpcs, typeof RequestTracing>>, RpcSerialization.RpcSerialization>, import("effect/Scope").Scope>, THandlers | RequestTracing | Rpc.ToHandler<Extract<TRpcs, {
|
|
86
|
+
readonly _tag: `${string}.$changes`;
|
|
87
|
+
}>>>, RpcSerialization.RpcSerialization>, never>>, HttpRouter.HttpRouter>, TServices>, import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/http/HttpServer").HttpServer | NodeServices.NodeServices>, NodeServices.NodeServices>, never>, never>, never>, AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>>;
|
|
88
|
+
//# sourceMappingURL=appHostHttp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appHostHttp.d.ts","sourceRoot":"","sources":["../src/appHostHttp.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAY,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAmC,UAAU,EAA2D,MAAM,aAAa,CAAC;AACnI,OAAO,EAAE,KAAK,GAAG,EAAE,gBAAgB,EAAa,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EAAqC,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAE3G,OAAO,EAA+C,KAAK,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAEvH,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAY7D,wBAAgB,WAAW,CAC1B,KAAK,SAAS,GAAG,CAAC,GAAG,EACrB,SAAS,EACT,aAAa,EACb,oBAAoB,EACp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AAa,CAAC,WAAW,CAAC,CAAC,EACvD,cAAc,EAAE,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;;ucAGjC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import { NodeHttpServer, NodeServices } from "@effect/platform-node";
|
|
3
|
+
import { ByteSize, Config, Effect, Layer } from "effect";
|
|
4
|
+
import { HttpEffect, HttpIncomingMessage, HttpRouter, HttpServerRequest, HttpServerResponse, HttpStaticServer } from "effect/http";
|
|
5
|
+
import { RpcSerialization, RpcServer } from "effect/rpc";
|
|
6
|
+
import { localRpcGuard } from "@shivaedev/identity/server/local.ts";
|
|
7
|
+
import { authenticatedLayer, maybeAuthenticatedLayer } from "@shivaedev/identity/server/session.ts";
|
|
8
|
+
import { requestTracingLayer } from "@shivaedev/identity/server/tracing.ts";
|
|
9
|
+
import { boundedRpcRequest } from "#boundedRpcRequest.ts";
|
|
10
|
+
import { healthRoute } from "#healthRoute.ts";
|
|
11
|
+
import { hostChanges } from "#hostChanges.ts";
|
|
12
|
+
import { hostTransport } from "#hostTransport.ts";
|
|
13
|
+
import { nativeClientOrigins } from "#nativeClientOrigins.ts";
|
|
14
|
+
import { otlpTracing } from "#otlpTracing.ts";
|
|
15
|
+
import { RedactionPolicy } from "#RedactionPolicy.ts";
|
|
16
|
+
import { redactingDiagnostics } from "#redactingDiagnostics.ts";
|
|
17
|
+
import { redactingRpcSerialization } from "#redactingRpcSerialization.ts";
|
|
18
|
+
import { schemaSensitiveKeys } from "#schemaSensitiveKeys.ts";
|
|
19
|
+
import { tracedGroup } from "#tracedGroup.ts";
|
|
20
|
+
const rpcCacheControl = (_, response) => Effect.succeed(HttpServerResponse.setHeader(response, "cache-control", "private, no-store"));
|
|
21
|
+
export function appHostHttp(options, changesService) {
|
|
22
|
+
const sensitive = schemaSensitiveKeys(options.group, options.config?.sensitiveKeys);
|
|
23
|
+
return Layer.unwrap(Effect.gen(function* () {
|
|
24
|
+
const { bodySize, trustedProxy, nativeOrigins } = yield* hostTransport(options);
|
|
25
|
+
const middleware = options.policy === "loopback"
|
|
26
|
+
? requestTracingLayer({ sensitive })
|
|
27
|
+
: Layer.mergeAll(authenticatedLayer(options.sessions), maybeAuthenticatedLayer(options.sessions), requestTracingLayer({ sensitive }));
|
|
28
|
+
const routes = HttpRouter.use((router) => Effect.gen(function* () {
|
|
29
|
+
const wire = redactingRpcSerialization(yield* RpcSerialization.RpcSerialization, sensitive, sensitive.maskFailure);
|
|
30
|
+
const handler = yield* RpcServer.toHttpEffect(tracedGroup(options.group)).pipe(Effect.provideService(RpcSerialization.RpcSerialization, wire));
|
|
31
|
+
const guarded = localRpcGuard(handler, trustedProxy, nativeOrigins);
|
|
32
|
+
if (nativeOrigins.length > 0) {
|
|
33
|
+
yield* router.add("OPTIONS", options.rpcPath ?? "/rpc", HttpServerResponse.text("Local same-origin requests only", { status: 403 }));
|
|
34
|
+
}
|
|
35
|
+
yield* router.add("POST", options.rpcPath ?? "/rpc", (request) => {
|
|
36
|
+
HttpEffect.appendPreResponseHandlerUnsafe(request, rpcCacheControl);
|
|
37
|
+
return guarded.pipe(Effect.provideService(HttpIncomingMessage.MaxBodySize, ByteSize.bytes(bodySize)), Effect.provideService(HttpServerRequest.HttpServerRequest, boundedRpcRequest(request)), Effect.provideService(RpcSerialization.RpcSerialization, wire));
|
|
38
|
+
});
|
|
39
|
+
})).pipe(Layer.provide(Layer.merge(middleware, hostChanges(options.group, changesService).pipe(Layer.provideMerge(options.handlers)))), Layer.provide(RpcSerialization.layerNdjson), Layer.provide(nativeClientOrigins(nativeOrigins, trustedProxy)));
|
|
40
|
+
const assets = options.assets === undefined
|
|
41
|
+
? Layer.empty
|
|
42
|
+
: HttpStaticServer.layer(typeof options.assets === "string" ? { root: options.assets } : options.assets);
|
|
43
|
+
const application = Layer.mergeAll(options.services ?? Layer.empty);
|
|
44
|
+
const server = Layer.unwrap(Effect.gen(function* () {
|
|
45
|
+
const port = options.config?.port ?? (yield* Config.Int("PORT").pipe(Config.withDefault(3000)));
|
|
46
|
+
const host = options.config?.host ?? (yield* Config.String("HOST").pipe(Config.withDefault("127.0.0.1")));
|
|
47
|
+
return NodeHttpServer.layer(createServer, {
|
|
48
|
+
gracefulShutdownTimeout: options.config?.gracefulShutdownTimeout,
|
|
49
|
+
host,
|
|
50
|
+
port,
|
|
51
|
+
...(options.config?.disablePreemptiveShutdown === undefined
|
|
52
|
+
? {}
|
|
53
|
+
: { disablePreemptiveShutdown: options.config.disablePreemptiveShutdown }),
|
|
54
|
+
});
|
|
55
|
+
}));
|
|
56
|
+
const applicationRoutes = (options.routes ?? Layer.empty).pipe(Layer.provide(options.nativeOrigins === undefined ? Layer.empty : nativeClientOrigins(nativeOrigins, trustedProxy, true)));
|
|
57
|
+
return HttpRouter.serve(Layer.mergeAll(routes, healthRoute, assets, applicationRoutes), { disableLogger: true }).pipe(Layer.provideMerge(application), Layer.provideMerge(server), Layer.provide(NodeServices.layer));
|
|
58
|
+
})).pipe(Layer.provide(redactingDiagnostics(sensitive)), Layer.provide(otlpTracing), Layer.provide(Layer.succeed(RedactionPolicy, sensitive)));
|
|
59
|
+
}
|
|
60
|
+
export function migratedHost(options, database, changesService) {
|
|
61
|
+
const services = Layer.mergeAll(options.services ?? Layer.empty);
|
|
62
|
+
return appHostHttp({ ...options, services: services.pipe(Layer.provideMerge(database)) }, changesService);
|
|
63
|
+
}
|
|
64
|
+
export function deferredHost(application, database, changesService) {
|
|
65
|
+
return Layer.unwrap(Effect.map(application, (options) => appHostHttp(options, changesService))).pipe(Layer.provideMerge(database));
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=appHostHttp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appHostHttp.js","sourceRoot":"","sources":["../src/appHostHttp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,YAAY,EA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AAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundedRpcRequest.d.ts","sourceRoot":"","sources":["../src/boundedRpcRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGtE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,iBAAiB,CAuBnH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { HttpServerError } from "effect/http";
|
|
3
|
+
import { readBoundedBody } from "@shivaedev/http/server/boundedBody.ts";
|
|
4
|
+
export function boundedRpcRequest(request) {
|
|
5
|
+
const arrayBuffer = readBoundedBody(request).pipe(Effect.mapError((cause) => cause._tag === "RequestBodyTooLarge"
|
|
6
|
+
? new HttpServerError.HttpServerError({ reason: new HttpServerError.RequestParseError({ cause, request }) })
|
|
7
|
+
: cause), Effect.cached, Effect.runSync);
|
|
8
|
+
const text = Effect.map(arrayBuffer, (body) => new TextDecoder().decode(body));
|
|
9
|
+
// The native text reader destroys the HTTP socket on overflow, preventing a 4xx response.
|
|
10
|
+
return new Proxy(request, {
|
|
11
|
+
get: (target, key, receiver) => {
|
|
12
|
+
if (key === "text") {
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
if (key === "arrayBuffer") {
|
|
16
|
+
return arrayBuffer;
|
|
17
|
+
}
|
|
18
|
+
return Reflect.get(target, key, receiver);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=boundedRpcRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundedRpcRequest.js","sourceRoot":"","sources":["../src/boundedRpcRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAA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,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAqBrG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Redacted } from "effect";
|
|
2
|
+
export function databaseAddress(value) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(Redacted.value(value));
|
|
5
|
+
if (url.protocol !== "postgres:" && url.protocol !== "postgresql:") {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
const hostname = url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : decodeURIComponent(url.hostname);
|
|
9
|
+
// PgConnection applies query parameters in order, after the authority.
|
|
10
|
+
const host = url.searchParams.getAll("host").at(-1) ?? hostname;
|
|
11
|
+
const rawPort = url.searchParams.getAll("port").at(-1) ?? url.port;
|
|
12
|
+
const port = rawPort === "" ? undefined : Number(rawPort);
|
|
13
|
+
if (host.includes(",") || (port !== undefined && (!Number.isInteger(port) || port < 1 || port > 65_535))) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
...(host === "" && !url.searchParams.has("host") ? {} : { host }),
|
|
18
|
+
...(port === undefined ? {} : { port }),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=databaseAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databaseAddress.js","sourceRoot":"","sources":["../src/databaseAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,UAAU,eAAe,CAAC,KAAgC;IAC/D,IAAI,CAAC;QACJ,MAAM,G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E,CAAC;YACjE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;SACvC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAC;IACX,CAAC;AACF,CAAC"}
|
|
@@ -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 type { SqlNameTransforms } from "@shivaedev/sql/clientOptions.ts";
|
|
5
|
+
import { type PostgresChangesOptions } from "@shivaedev/sql/postgresChanges.ts";
|
|
6
|
+
import type { AppChanges, AppDatabaseOptions } from "#appHost.ts";
|
|
7
|
+
export interface DatabaseConfig extends SqlNameTransforms {
|
|
8
|
+
readonly applicationName?: string;
|
|
9
|
+
readonly changes?: Partial<Omit<PostgresChangesOptions, "client" | "resync">>;
|
|
10
|
+
readonly databaseUrl?: Redacted.Redacted<string>;
|
|
11
|
+
readonly maxConnections?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function databaseLayer<R>(options: AppDatabaseOptions<R>, changesService: typeof AppChanges): Layer.Layer<AppChanges | PgClient.PgClient | Reactivity.Reactivity | import("effect/sql/SqlClient").SqlClient, Config.ConfigError | import("effect/sql/Migrator").MigrationError | import("effect/sql/SqlError").SqlError, Exclude<Exclude<R, import("effect/Scope").Scope>, PgClient.PgClient | import("effect/sql/SqlClient").SqlClient>>;
|
|
14
|
+
//# sourceMappingURL=databaseLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databaseLayer.d.ts","sourceRoot":"","sources":["../src/databaseLayer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAA2B,KAAK,EAAE,QAAQ,EAAY,MAAM,QAAQ,CAAC;AACpF,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIzE,OAAO,EAAE,KAAK,sBAAsB,EAAmB,MAAM,mCAAmC,CAAC;AAEjG,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGlE,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACxD,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC9E,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,UAAU,+UAmDjG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { createConnection } from "node:net";
|
|
3
|
+
import * as PgClient from "@effect/sql-pg/PgClient";
|
|
4
|
+
import { Config, Duration, Effect, Fiber, Layer, Redacted, Schedule } from "effect";
|
|
5
|
+
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
6
|
+
import { makeLiveServer } from "@shivaedev/contract/makeLiveServer.ts";
|
|
7
|
+
import { assertPostgresMigrations, postgresMigrationError } from "@shivaedev/sql/assertPostgresMigrations.ts";
|
|
8
|
+
import { coordinateWorkerRelease } from "@shivaedev/sql/coordinateWorkerRelease.ts";
|
|
9
|
+
import { migratePostgres } from "@shivaedev/sql/migrations.ts";
|
|
10
|
+
import { pendingPostgresMigrations } from "@shivaedev/sql/pendingPostgresMigrations.ts";
|
|
11
|
+
import { postgresChanges } from "@shivaedev/sql/postgresChanges.ts";
|
|
12
|
+
import { WorkerRelease } from "@shivaedev/sql/WorkerRelease.ts";
|
|
13
|
+
import { databaseAddress } from "./databaseAddress.js";
|
|
14
|
+
export function databaseLayer(options, changesService) {
|
|
15
|
+
const pool = Layer.unwrap(Effect.gen(function* () {
|
|
16
|
+
const url = options.config?.databaseUrl ?? (yield* Config.Redacted("DATABASE_URL"));
|
|
17
|
+
const address = databaseAddress(url);
|
|
18
|
+
const disconnected = new Set();
|
|
19
|
+
// Native pool shutdown sends Terminate without waiting for its sockets to close.
|
|
20
|
+
yield* Effect.addFinalizer(() => Effect.promise(() => Promise.all([...disconnected])));
|
|
21
|
+
return PgClient.layer({
|
|
22
|
+
stream: () => {
|
|
23
|
+
const target = new URL(Redacted.value(url));
|
|
24
|
+
const host = address.host ?? target.searchParams.getAll("host").at(-1) ?? (decodeURIComponent(target.hostname) || "localhost");
|
|
25
|
+
const port = address.port ?? 5432;
|
|
26
|
+
const socket = createConnection(host.startsWith("/") ? { path: `${host}/.s.PGSQL.${port}` } : { host, noDelay: true, port });
|
|
27
|
+
const closed = new Promise((resolve) => socket.once("close", () => {
|
|
28
|
+
disconnected.delete(closed);
|
|
29
|
+
resolve();
|
|
30
|
+
}));
|
|
31
|
+
disconnected.add(closed);
|
|
32
|
+
return socket;
|
|
33
|
+
},
|
|
34
|
+
transformQueryNames: options.config?.transformQueryNames,
|
|
35
|
+
transformResultNames: options.config?.transformResultNames,
|
|
36
|
+
url,
|
|
37
|
+
...address,
|
|
38
|
+
...(options.config?.maxConnections === undefined ? {} : { maxConnections: options.config.maxConnections }),
|
|
39
|
+
...(options.config?.applicationName === undefined ? {} : { applicationName: options.config.applicationName }),
|
|
40
|
+
});
|
|
41
|
+
}));
|
|
42
|
+
const prepared = Layer.effectDiscard(prepareMigrations(options.migrations)).pipe(Layer.provideMerge(pool));
|
|
43
|
+
const live = Layer.effect(changesService, makeLiveServer).pipe(Layer.provideMerge(Reactivity.layer));
|
|
44
|
+
const migrations = options.migrations;
|
|
45
|
+
const worker = migrations.mode === "wait" && migrations.release !== undefined
|
|
46
|
+
? Layer.effect(WorkerRelease, coordinateWorkerRelease(migrations.release, migrations.pollInterval, migrations.table))
|
|
47
|
+
: Layer.empty;
|
|
48
|
+
const base = Layer.merge(worker.pipe(Layer.provideMerge(prepared)), live);
|
|
49
|
+
const changes = options.config?.changes;
|
|
50
|
+
return Layer.unwrap(Effect.gen(function* () {
|
|
51
|
+
const client = yield* PgClient.PgClient;
|
|
52
|
+
const hints = yield* changesService;
|
|
53
|
+
const url = options.config?.databaseUrl ?? (yield* Config.Redacted("DATABASE_URL"));
|
|
54
|
+
const name = yield* Config.String("APP_NAME").pipe(Config.withDefault(new URL(Redacted.value(url)).pathname));
|
|
55
|
+
const channel = changes?.channel ?? `changes_${createHash("sha256").update(name).digest("hex").slice(0, 32)}`;
|
|
56
|
+
return postgresChanges({ ...changes, channel, client, resync: hints.resync });
|
|
57
|
+
})).pipe(Layer.provideMerge(base));
|
|
58
|
+
}
|
|
59
|
+
function prepareMigrations(migrations) {
|
|
60
|
+
switch (migrations.mode) {
|
|
61
|
+
case "check": {
|
|
62
|
+
const schema = { ...migrations };
|
|
63
|
+
delete schema.release;
|
|
64
|
+
return assertPostgresMigrations(schema);
|
|
65
|
+
}
|
|
66
|
+
case "wait":
|
|
67
|
+
return waitForMigrations(migrations);
|
|
68
|
+
default:
|
|
69
|
+
return migratePostgres({ ...migrations, lockTimeout: migrations.lockTimeout ?? "5 seconds" }).pipe(Effect.asVoid);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function waitForMigrations(migrations) {
|
|
73
|
+
return Effect.gen(function* () {
|
|
74
|
+
const progressInterval = Duration.fromInputUnsafe(migrations.progressInterval ?? "30 seconds");
|
|
75
|
+
let pending = { components: [], migrations: [] };
|
|
76
|
+
let progress;
|
|
77
|
+
function log(message) {
|
|
78
|
+
return Effect.suspend(() => Effect.logInfo(message).pipe(Effect.annotateLogs({ pendingComponents: pending.components, pendingMigrations: pending.migrations })));
|
|
79
|
+
}
|
|
80
|
+
yield* Effect.gen(function* () {
|
|
81
|
+
pending = yield* pendingPostgresMigrations(migrations);
|
|
82
|
+
if (pending.migrations.length === 0 && pending.components.length === 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (progress === undefined) {
|
|
86
|
+
yield* log("Waiting for database migrations");
|
|
87
|
+
progress = yield* Effect.forever(Effect.sleep(progressInterval).pipe(Effect.andThen(log("Still waiting for database migrations")))).pipe(Effect.forkScoped);
|
|
88
|
+
}
|
|
89
|
+
return yield* Effect.fail(postgresMigrationError(pending));
|
|
90
|
+
}).pipe(Effect.retry({
|
|
91
|
+
schedule: Schedule.max([Schedule.spaced(migrations.pollInterval ?? "1 second"), Schedule.during(migrations.waitTimeout ?? "5 minutes")]),
|
|
92
|
+
while: (error) => error._tag === "MigrationError" && error.kind === "BadState",
|
|
93
|
+
}), Effect.tapError((error) => error._tag === "MigrationError" && error.kind === "BadState" ? log("Timed out waiting for database migrations") : Effect.void));
|
|
94
|
+
if (progress !== undefined) {
|
|
95
|
+
yield* Fiber.interrupt(progress);
|
|
96
|
+
yield* Effect.logInfo("Database migrations current");
|
|
97
|
+
}
|
|
98
|
+
}).pipe(Effect.scoped);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=databaseLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databaseLayer.js","sourceRoot":"","sources":["../src/databaseLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QA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M,CAAC,KAAK,CAAC;YACZ,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,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,CAAC,IAAI,KAAK,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;SAC9E,CAAC,EACF,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACzB,KAAK,CAAC,IAAI,KAAK,gBAAgB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAC7H,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { ChildProcessSpawner } from "effect/process";
|
|
3
|
+
export interface DevelopmentOptions {
|
|
4
|
+
readonly conditions?: readonly string[];
|
|
5
|
+
readonly server: string;
|
|
6
|
+
readonly worker: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const development: (args_0: DevelopmentOptions) => Effect.Effect<ChildProcessSpawner.ExitCode, import("effect/PlatformError").PlatformError, ChildProcessSpawner.ChildProcessSpawner>;
|
|
9
|
+
export declare function runDevelopment(options: DevelopmentOptions): void;
|
|
10
|
+
//# sourceMappingURL=development.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"development.d.ts","sourceRoot":"","sources":["../src/development.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,WAAW,oKAStB,CAAC;AAEH,wBAAgB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAWhE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { NodeRuntime, NodeServices } from "@effect/platform-node";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
5
|
+
export const development = Effect.fn("Platform.development")(function* ({ server, worker, conditions = [] }) {
|
|
6
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
7
|
+
const options = { stderr: "inherit", stdout: "inherit" };
|
|
8
|
+
const args = [...conditions.map((condition) => `--conditions=${condition}`), "--watch"];
|
|
9
|
+
return yield* Effect.raceAll([
|
|
10
|
+
spawner.exitCode(ChildProcess.make(process.execPath, [...args, server], options)),
|
|
11
|
+
spawner.exitCode(ChildProcess.make(process.execPath, [...args, worker], options)),
|
|
12
|
+
spawner.exitCode(ChildProcess.make("pnpm", ["exec", "vite"], options)),
|
|
13
|
+
]);
|
|
14
|
+
});
|
|
15
|
+
export function runDevelopment(options) {
|
|
16
|
+
NodeRuntime.runMain(development(options).pipe(Effect.tap((code) => Effect.sync(() => {
|
|
17
|
+
process.exitCode = code;
|
|
18
|
+
})), Effect.provide(NodeServices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AAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;KACtE,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,OAA2B;IACzD,WAAW,CAAC,OAAO,CAClB,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CACxB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACnB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QAChB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzB,CAAC,CAAC,CACF,EACD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAClC,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"healthRoute.d.ts","sourceRoot":"","sources":["../src/healthRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAG7D,eAAO,MAAM,WAAW,mEAsBvB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Effect, Fiber, Option } from "effect";
|
|
2
|
+
import { HttpRouter, HttpServerResponse } from "effect/http";
|
|
3
|
+
import { SqlClient } from "effect/sql";
|
|
4
|
+
export const healthRoute = HttpRouter.use((router) => Effect.gen(function* () {
|
|
5
|
+
const database = yield* Effect.serviceOption(SqlClient.SqlClient);
|
|
6
|
+
const scope = yield* Effect.scope;
|
|
7
|
+
const probe = Effect.gen(function* () {
|
|
8
|
+
if (Option.isNone(database)) {
|
|
9
|
+
return 503;
|
|
10
|
+
}
|
|
11
|
+
const query = yield* database.value `select 1`.pipe(Effect.forkIn(scope));
|
|
12
|
+
return yield* Fiber.join(query).pipe(Effect.timeout("2 seconds"),
|
|
13
|
+
// Driver cancellation may need network I/O; keep cleanup in the host scope without delaying the response.
|
|
14
|
+
Effect.ensuring(Fiber.interrupt(query).pipe(Effect.forkIn(scope), Effect.asVoid)), Effect.match({ onFailure: () => 503, onSuccess: () => 200 }));
|
|
15
|
+
});
|
|
16
|
+
yield* router.add("GET", "/health", Effect.map(probe, (status) => HttpServerResponse.empty({ headers: { "cache-control": "no-store" }, status })));
|
|
17
|
+
}));
|
|
18
|
+
//# sourceMappingURL=healthRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"healthRoute.js","sourceRoot":"","sources":["../src/healthRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACpD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACnB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACjC,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAA,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACzE,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CACnC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;QAC3B,0GAA0G;QAC1G,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EACjF,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAC5D,CAAC;IACH,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAChB,KAAK,EACL,SAAS,EACT,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAC7G,CAAC;AACH,CAAC,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import type { Rpc, RpcGroup } from "effect/rpc";
|
|
3
|
+
import type { AppChanges } from "./appHost.ts";
|
|
4
|
+
export declare function hostChanges<R extends Rpc.Any>(group: RpcGroup.RpcGroup<R>, changesService: typeof AppChanges): Layer.Layer<Rpc.ToHandler<Extract<R, {
|
|
5
|
+
readonly _tag: `${string}.$changes`;
|
|
6
|
+
}>>, never, never>;
|
|
7
|
+
//# sourceMappingURL=hostChanges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostChanges.d.ts","sourceRoot":"","sources":["../src/hostChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,wBAAgB,WAAW,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,UAAU;mBAwBtC,GAAG,MAAM,WAAW;mBAG1F"}
|