@shivaedev/server 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +81 -17
- package/dist/AppModule.d.ts +22 -0
- package/dist/AppModule.d.ts.map +1 -0
- package/dist/AppModule.js +2 -0
- package/dist/AppModule.js.map +1 -0
- package/dist/DuplicateModuleQueue.d.ts +11 -0
- package/dist/DuplicateModuleQueue.d.ts.map +1 -0
- package/dist/DuplicateModuleQueue.js +11 -0
- package/dist/DuplicateModuleQueue.js.map +1 -0
- package/dist/{runtime/makePlatform.d.ts → adapters/makePlatformRuntime.d.ts} +2 -2
- package/dist/adapters/makePlatformRuntime.d.ts.map +1 -0
- package/dist/{runtime/makePlatform.js → adapters/makePlatformRuntime.js} +1 -1
- package/dist/adapters/makePlatformRuntime.js.map +1 -0
- package/dist/{nodeHttpServer.d.ts → adapters/nodeHttpServer.d.ts} +1 -0
- package/dist/adapters/nodeHttpServer.d.ts.map +1 -0
- package/dist/{nodeHttpServer.js → adapters/nodeHttpServer.js} +5 -0
- package/dist/adapters/nodeHttpServer.js.map +1 -0
- package/dist/adapters/subscriptionSignal.d.ts.map +1 -0
- package/dist/adapters/subscriptionSignal.js.map +1 -0
- package/dist/appDatabase.d.ts +2 -2
- package/dist/appDatabase.d.ts.map +1 -1
- package/dist/appDatabase.js +8 -3
- package/dist/appDatabase.js.map +1 -1
- package/dist/appHost.d.ts.map +1 -1
- package/dist/appHost.js +11 -4
- package/dist/appHost.js.map +1 -1
- package/dist/appHostHttp.d.ts +48 -30
- package/dist/appHostHttp.d.ts.map +1 -1
- package/dist/appHostHttp.js +2 -2
- package/dist/appHostHttp.js.map +1 -1
- package/dist/appModules.d.ts +37 -0
- package/dist/appModules.d.ts.map +1 -0
- package/dist/appModules.js +37 -0
- package/dist/appModules.js.map +1 -0
- package/dist/boundedRpcRequest.d.ts +3 -2
- package/dist/boundedRpcRequest.d.ts.map +1 -1
- package/dist/boundedRpcRequest.js +6 -5
- package/dist/boundedRpcRequest.js.map +1 -1
- package/dist/boundedRpcSocket.d.ts +4 -0
- package/dist/boundedRpcSocket.d.ts.map +1 -0
- package/dist/boundedRpcSocket.js +29 -0
- package/dist/boundedRpcSocket.js.map +1 -0
- package/dist/browserErrorRoute.js +1 -1
- package/dist/browserErrorRoute.js.map +1 -1
- package/dist/hostChanges.d.ts +4 -2
- package/dist/hostChanges.d.ts.map +1 -1
- package/dist/hostChanges.js +37 -42
- package/dist/hostChanges.js.map +1 -1
- package/dist/hostRpc.d.ts +4 -9
- package/dist/hostRpc.d.ts.map +1 -1
- package/dist/hostRpc.js +9 -17
- package/dist/hostRpc.js.map +1 -1
- package/dist/hostRpcRoutes.d.ts +5 -3
- package/dist/hostRpcRoutes.d.ts.map +1 -1
- package/dist/hostRpcRoutes.js +5 -4
- package/dist/hostRpcRoutes.js.map +1 -1
- package/dist/hostTransport.js +1 -1
- package/dist/hostTransport.js.map +1 -1
- package/dist/nativeClientOrigins.js +1 -1
- package/dist/nativeClientOrigins.js.map +1 -1
- package/dist/otlpHttpClient.js +2 -2
- package/dist/otlpHttpClient.js.map +1 -1
- package/dist/otlpTracing.d.ts.map +1 -1
- package/dist/otlpTracing.js +4 -4
- package/dist/otlpTracing.js.map +1 -1
- package/dist/publishCommand.d.ts +3 -0
- package/dist/publishCommand.d.ts.map +1 -0
- package/dist/publishCommand.js +36 -0
- package/dist/publishCommand.js.map +1 -0
- package/dist/redactingRpcSerialization.d.ts +3 -2
- package/dist/redactingRpcSerialization.d.ts.map +1 -1
- package/dist/redactingRpcSerialization.js +8 -8
- package/dist/redactingRpcSerialization.js.map +1 -1
- package/dist/rerunQuery.d.ts +7 -3
- package/dist/rerunQuery.d.ts.map +1 -1
- package/dist/rerunQuery.js +3 -4
- package/dist/rerunQuery.js.map +1 -1
- package/dist/setupDatabases.d.ts +1 -1
- package/dist/setupDatabases.d.ts.map +1 -1
- package/dist/setupDatabases.js +3 -3
- package/dist/setupDatabases.js.map +1 -1
- package/dist/socketRpc.js +1 -1
- package/dist/socketRpc.js.map +1 -1
- package/dist/testing/HostProcessError.d.ts +10 -0
- package/dist/testing/HostProcessError.d.ts.map +1 -0
- package/dist/testing/HostProcessError.js +4 -0
- package/dist/testing/HostProcessError.js.map +1 -0
- package/dist/testing/adapters/hostProcess.d.ts +23 -0
- package/dist/testing/adapters/hostProcess.d.ts.map +1 -0
- package/dist/testing/adapters/hostProcess.js +84 -0
- package/dist/testing/adapters/hostProcess.js.map +1 -0
- package/dist/testing/adapters/hostProcessReadouts.d.ts +10 -0
- package/dist/testing/adapters/hostProcessReadouts.d.ts.map +1 -0
- package/dist/testing/adapters/hostProcessReadouts.js +26 -0
- package/dist/testing/adapters/hostProcessReadouts.js.map +1 -0
- package/dist/testing/hostProcess.d.ts +24 -0
- package/dist/testing/hostProcess.d.ts.map +1 -0
- package/dist/testing/hostProcess.js +49 -0
- package/dist/testing/hostProcess.js.map +1 -0
- package/dist/testing/hostProcessChild.d.ts +6 -0
- package/dist/testing/hostProcessChild.d.ts.map +1 -0
- package/dist/testing/hostProcessChild.js +15 -0
- package/dist/testing/hostProcessChild.js.map +1 -0
- package/dist/testing/hostProcessProtocol.d.ts +17 -0
- package/dist/testing/hostProcessProtocol.d.ts.map +1 -0
- package/dist/testing/hostProcessProtocol.js +10 -0
- package/dist/testing/hostProcessProtocol.js.map +1 -0
- package/dist/testing/hostProcessReadouts.d.ts +7 -0
- package/dist/testing/hostProcessReadouts.d.ts.map +1 -0
- package/dist/testing/hostProcessReadouts.js +37 -0
- package/dist/testing/hostProcessReadouts.js.map +1 -0
- package/dist/workerHost.d.ts +7 -0
- package/dist/workerHost.d.ts.map +1 -0
- package/dist/workerHost.js +7 -0
- package/dist/workerHost.js.map +1 -0
- package/package.json +25 -17
- package/src/AppModule.ts +19 -0
- package/src/DuplicateModuleQueue.ts +11 -0
- package/src/{runtime/makePlatform.ts → adapters/makePlatformRuntime.ts} +1 -1
- package/src/{nodeHttpServer.ts → adapters/nodeHttpServer.ts} +7 -0
- package/src/appDatabase.ts +9 -3
- package/src/appHost.ts +17 -7
- package/src/appHostHttp.ts +2 -2
- package/src/appModules.ts +99 -0
- package/src/boundedRpcRequest.ts +6 -5
- package/src/boundedRpcSocket.ts +32 -0
- package/src/browserErrorRoute.ts +1 -1
- package/src/hostChanges.ts +66 -50
- package/src/hostRpc.ts +9 -23
- package/src/hostRpcRoutes.ts +22 -12
- package/src/hostTransport.ts +1 -1
- package/src/nativeClientOrigins.ts +1 -1
- package/src/otlpHttpClient.ts +2 -2
- package/src/otlpTracing.ts +8 -6
- package/src/publishCommand.ts +47 -0
- package/src/redactingRpcSerialization.ts +11 -12
- package/src/rerunQuery.ts +18 -6
- package/src/setupDatabases.ts +3 -3
- package/src/socketRpc.ts +1 -1
- package/src/testing/HostProcessError.ts +6 -0
- package/src/testing/adapters/hostProcess.ts +95 -0
- package/src/testing/adapters/hostProcessReadouts.ts +29 -0
- package/src/testing/hostProcess.ts +60 -0
- package/src/testing/hostProcessChild.ts +20 -0
- package/src/testing/hostProcessProtocol.ts +10 -0
- package/src/testing/hostProcessReadouts.ts +46 -0
- package/src/workerHost.ts +13 -0
- package/dist/node-http/subscriptionSignal.d.ts.map +0 -1
- package/dist/node-http/subscriptionSignal.js.map +0 -1
- package/dist/nodeHttpServer.d.ts.map +0 -1
- package/dist/nodeHttpServer.js.map +0 -1
- package/dist/runtime/makePlatform.d.ts.map +0 -1
- package/dist/runtime/makePlatform.js.map +0 -1
- /package/dist/{node-http → adapters}/subscriptionSignal.d.ts +0 -0
- /package/dist/{node-http → adapters}/subscriptionSignal.js +0 -0
- /package/src/{node-http → adapters}/subscriptionSignal.ts +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Effect, Redacted, Schema } from "effect";
|
|
2
|
+
import { forkHost, hostResponse, receiveHostMessage, stopHost } from "#testing/adapters/hostProcess.ts";
|
|
3
|
+
import { collectHostReadouts } from "#testing/adapters/hostProcessReadouts.ts";
|
|
4
|
+
import { HostProcessError } from "./HostProcessError.js";
|
|
5
|
+
import { HostReady, HostSignal } from "./hostProcessProtocol.js";
|
|
6
|
+
export const hostProcess = Effect.fn("HostProcess.hostProcess")(function* (options) {
|
|
7
|
+
const databaseUrl = options.databaseUrl;
|
|
8
|
+
const database = databaseUrl === undefined
|
|
9
|
+
? undefined
|
|
10
|
+
: yield* Effect.promise(() => import("@shivaedev/test-sql/server/disconnectProxy.ts")).pipe(Effect.flatMap(({ disconnectProxy }) => disconnectProxy(Redacted.value(databaseUrl))));
|
|
11
|
+
const child = yield* Effect.acquireRelease(Effect.try({ catch: (cause) => new HostProcessError({ cause, operation: "launch" }), try: () => forkHost(options, database?.url) }), (acquired) => Effect.promise(() => stopHost(acquired)));
|
|
12
|
+
const read = collectHostReadouts(child);
|
|
13
|
+
const { pid, url } = yield* Effect.tryPromise({
|
|
14
|
+
catch: (cause) => new HostProcessError({ cause, operation: "launch" }),
|
|
15
|
+
try: (signal) => receiveHostMessage(child, HostReady, signal),
|
|
16
|
+
});
|
|
17
|
+
function response(path) {
|
|
18
|
+
return Effect.tryPromise({
|
|
19
|
+
catch: (cause) => new HostProcessError({ cause, operation: "request" }),
|
|
20
|
+
try: (signal) => hostResponse(url, path, signal),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function readouts() {
|
|
24
|
+
return Effect.tryPromise({
|
|
25
|
+
catch: (cause) => new HostProcessError({ cause, operation: "readout" }),
|
|
26
|
+
try: read,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
activeWork: () => readouts().pipe(Effect.map((state) => state.activeWork)),
|
|
31
|
+
disconnectIdlePostgres: () => Effect.suspend(() => database === undefined
|
|
32
|
+
? Effect.die(new Error("Launch the host with databaseUrl before disconnecting PostgreSQL"))
|
|
33
|
+
: Effect.sync(database.disconnect)),
|
|
34
|
+
finalizers: () => readouts().pipe(Effect.map((state) => state.finalizers)),
|
|
35
|
+
headers: (path) => response(path).pipe(Effect.map((answer) => answer.headers)),
|
|
36
|
+
health: () => response("/health"),
|
|
37
|
+
pid,
|
|
38
|
+
shutdownDuration: () => readouts().pipe(Effect.map((state) => state.shutdownDuration)),
|
|
39
|
+
signal: (delivered) => Effect.tryPromise({
|
|
40
|
+
catch: (cause) => new HostProcessError({ cause, operation: "signal" }),
|
|
41
|
+
try: (signal) => receiveHostMessage(child, HostSignal.pipe(Schema.check(Schema.makeFilter((ack) => ack.signal === delivered))), signal, () => {
|
|
42
|
+
child.kill(delivered);
|
|
43
|
+
}),
|
|
44
|
+
}).pipe(Effect.asVoid),
|
|
45
|
+
stop: () => Effect.promise(() => stopHost(child)),
|
|
46
|
+
url,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=hostProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcess.js","sourceRoot":"","sources":["../../src/testing/hostProcess.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { HttpServer } from "effect/http";
|
|
3
|
+
import { HostProcessError } from "#testing/HostProcessError.ts";
|
|
4
|
+
export declare const reportHostReady: Effect.Effect<void, HostProcessError, HttpServer.HttpServer>;
|
|
5
|
+
export declare function acknowledgeHostSignal(signal: NodeJS.Signals): Effect.Effect<void, HostProcessError, never>;
|
|
6
|
+
//# sourceMappingURL=hostProcessChild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcessChild.d.ts","sourceRoot":"","sources":["../../src/testing/hostProcessChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,eAAO,MAAM,eAAe,8DAO3B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,gDAK3D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { HttpServer } from "effect/http";
|
|
3
|
+
import { sendHostMessage, sendHostReady } from "#testing/adapters/hostProcess.ts";
|
|
4
|
+
import { HostProcessError } from "#testing/HostProcessError.ts";
|
|
5
|
+
export const reportHostReady = HttpServer.HttpServer.pipe(Effect.flatMap((server) => Effect.tryPromise({
|
|
6
|
+
catch: (cause) => new HostProcessError({ cause, operation: "launch" }),
|
|
7
|
+
try: () => sendHostReady(HttpServer.formatAddress(server.address)),
|
|
8
|
+
})));
|
|
9
|
+
export function acknowledgeHostSignal(signal) {
|
|
10
|
+
return Effect.tryPromise({
|
|
11
|
+
catch: (cause) => new HostProcessError({ cause, operation: "signal" }),
|
|
12
|
+
try: () => sendHostMessage({ signal, type: "host-signal" }),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=hostProcessChild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcessChild.js","sourceRoot":"","sources":["../../src/testing/hostProcessChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CACxD,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CACzB,MAAM,CAAC,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;CAClE,CAAC,CACF,CACD,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IAC3D,OAAO,MAAM,CAAC,UAAU,CAAC;QACxB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtE,GAAG,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KAC3D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const HostReady: Schema.Struct<{
|
|
3
|
+
readonly pid: Schema.Number;
|
|
4
|
+
readonly type: Schema.Literal<"host-ready">;
|
|
5
|
+
readonly url: Schema.String;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const HostSignal: Schema.Struct<{
|
|
8
|
+
readonly signal: Schema.String;
|
|
9
|
+
readonly type: Schema.Literal<"host-signal">;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const HostReadouts: Schema.Struct<{
|
|
12
|
+
readonly activeWork: Schema.$Array<Schema.String>;
|
|
13
|
+
readonly finalizers: Schema.$Array<Schema.String>;
|
|
14
|
+
readonly shutdownDuration: Schema.NullOr<Schema.Number>;
|
|
15
|
+
readonly type: Schema.Literal<"host-readouts">;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=hostProcessProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcessProtocol.d.ts","sourceRoot":"","sources":["../../src/testing/hostProcessProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,SAAS;;;;EAAgG,CAAC;AACvH,eAAO,MAAM,UAAU;;;EAAgF,CAAC;AACxG,eAAO,MAAM,YAAY;;;;;EAKvB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export const HostReady = Schema.Struct({ pid: Schema.Number, type: Schema.Literal("host-ready"), url: Schema.String });
|
|
3
|
+
export const HostSignal = Schema.Struct({ signal: Schema.String, type: Schema.Literal("host-signal") });
|
|
4
|
+
export const HostReadouts = Schema.Struct({
|
|
5
|
+
activeWork: Schema.Array(Schema.String),
|
|
6
|
+
finalizers: Schema.Array(Schema.String),
|
|
7
|
+
shutdownDuration: Schema.NullOr(Schema.Number),
|
|
8
|
+
type: Schema.Literal("host-readouts"),
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=hostProcessProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcessProtocol.js","sourceRoot":"","sources":["../../src/testing/hostProcessProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACvH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;AACxG,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;CACrC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export declare const hostProcessReadouts: Effect.Effect<{
|
|
3
|
+
finalizer: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
4
|
+
shutdown: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
5
|
+
work: <A, E, R>(name: string, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
6
|
+
}, never, import("effect/Scope").Scope>;
|
|
7
|
+
//# sourceMappingURL=hostProcessReadouts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcessReadouts.d.ts","sourceRoot":"","sources":["../../src/testing/hostProcessReadouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKjD,eAAO,MAAM,mBAAmB;gBAsBlB,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,MAAM,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;eACtD,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;WAM3C,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,MAAM,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;uCAW5D,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Clock, Duration, Effect } from "effect";
|
|
2
|
+
import { sendHostMessage } from "#testing/adapters/hostProcess.ts";
|
|
3
|
+
import { listenHostReadouts } from "#testing/adapters/hostProcessReadouts.ts";
|
|
4
|
+
import { HostProcessError } from "./HostProcessError.js";
|
|
5
|
+
export const hostProcessReadouts = Effect.gen(function* () {
|
|
6
|
+
const active = new Map();
|
|
7
|
+
const finalizers = [];
|
|
8
|
+
let shutdownDuration = null;
|
|
9
|
+
let shutdownWork;
|
|
10
|
+
function read() {
|
|
11
|
+
return { activeWork: shutdownWork ?? [...active.values()], finalizers: [...finalizers], shutdownDuration, type: "host-readouts" };
|
|
12
|
+
}
|
|
13
|
+
function finishShutdown(started) {
|
|
14
|
+
return Effect.gen(function* () {
|
|
15
|
+
shutdownDuration = Duration.toMillis(Duration.nanos((yield* Clock.currentTimeNanos) - started));
|
|
16
|
+
yield* Effect.tryPromise({
|
|
17
|
+
catch: (cause) => new HostProcessError({ cause, operation: "readout" }),
|
|
18
|
+
try: () => sendHostMessage(read()),
|
|
19
|
+
}).pipe(Effect.orDie);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
yield* Effect.acquireRelease(Effect.sync(() => listenHostReadouts(read)), (close) => Effect.sync(close));
|
|
23
|
+
return {
|
|
24
|
+
finalizer: (name, effect) => effect.pipe(Effect.ensuring(Effect.sync(() => finalizers.push(name)))),
|
|
25
|
+
shutdown: (effect) => Effect.gen(function* () {
|
|
26
|
+
shutdownWork = [...active.values()];
|
|
27
|
+
const started = yield* Clock.currentTimeNanos;
|
|
28
|
+
return yield* effect.pipe(Effect.ensuring(finishShutdown(started)));
|
|
29
|
+
}),
|
|
30
|
+
work: (name, effect) => Effect.acquireUseRelease(Effect.sync(() => {
|
|
31
|
+
const id = Symbol(name);
|
|
32
|
+
active.set(id, name);
|
|
33
|
+
return id;
|
|
34
|
+
}), () => effect, (id) => Effect.sync(() => active.delete(id))),
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=hostProcessReadouts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcessReadouts.js","sourceRoot":"","sources":["../../src/testing/hostProcessReadouts.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import type { AppDatabaseOptions } from "#appHost.ts";
|
|
3
|
+
export declare function workerHost<R, E, TRequirements, TServices, TServiceError, TServiceRequirements, TMigrations = never, TMigrationError = never>(options: AppDatabaseOptions<TMigrations, TMigrationError> & {
|
|
4
|
+
readonly workers: Layer.Layer<R, E, TRequirements>;
|
|
5
|
+
readonly services: Layer.Layer<TServices, TServiceError, TServiceRequirements>;
|
|
6
|
+
}): Layer.Layer<"@shivaedev/contract/LiveServer" | R | TServices | import("@effect/sql-pg/PgClient").PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient, E | TMigrationError | TServiceError | 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<TServiceRequirements, "@shivaedev/contract/LiveServer" | import("@effect/sql-pg/PgClient").PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<TMigrations, import("effect/Scope").Scope>, "@shivaedev/contract/LiveServer" | import("@effect/sql-pg/PgClient").PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/Crypto").Crypto> | Exclude<Exclude<Exclude<TRequirements, TServices>, "@shivaedev/contract/LiveServer" | import("@effect/sql-pg/PgClient").PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient>, import("effect/Crypto").Crypto>>;
|
|
7
|
+
//# sourceMappingURL=workerHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerHost.d.ts","sourceRoot":"","sources":["../src/workerHost.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,WAAW,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK,EAC3I,OAAO,EAAE,kBAAkB,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG;IAC3D,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;CAC/E,m5CAGD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
2
|
+
import { Layer } from "effect";
|
|
3
|
+
import { appDatabase } from "#appDatabase.ts";
|
|
4
|
+
export function workerHost(options) {
|
|
5
|
+
return options.workers.pipe(Layer.provideMerge(options.services), Layer.provideMerge(appDatabase(options)), Layer.provide(NodeCrypto.layer));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=workerHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerHost.js","sourceRoot":"","sources":["../src/workerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,MAAM,UAAU,UAAU,CACzB,OAGC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9I,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "The Effect application host: HTTP and RPC serving, health, OTLP export, database and migrations, and development mode",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -45,27 +45,27 @@
|
|
|
45
45
|
"README.md"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@shivaedev/changes": "0.
|
|
49
|
-
"@shivaedev/contract": "0.
|
|
50
|
-
"@shivaedev/errors": "0.
|
|
51
|
-
"@shivaedev/http": "0.
|
|
52
|
-
"@shivaedev/identity": "0.
|
|
53
|
-
"@shivaedev/local-postgres": "0.
|
|
54
|
-
"@shivaedev/sql": "0.
|
|
48
|
+
"@shivaedev/changes": "0.9.0",
|
|
49
|
+
"@shivaedev/contract": "0.32.0",
|
|
50
|
+
"@shivaedev/errors": "0.6.0",
|
|
51
|
+
"@shivaedev/http": "0.5.0",
|
|
52
|
+
"@shivaedev/identity": "0.20.0",
|
|
53
|
+
"@shivaedev/local-postgres": "0.11.0",
|
|
54
|
+
"@shivaedev/sql": "0.34.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@effect/platform-node": "4.0.6",
|
|
58
58
|
"@effect/sql-pg": "4.0.6",
|
|
59
59
|
"@effect/vitest": "4.0.6",
|
|
60
|
-
"@shivaedev/access": "0.
|
|
61
|
-
"@shivaedev/admin": "0.
|
|
62
|
-
"@shivaedev/jobs": "0.
|
|
63
|
-
"@shivaedev/quality": "0.
|
|
64
|
-
"@shivaedev/
|
|
65
|
-
"@shivaedev/test-sql": "0.
|
|
66
|
-
"@shivaedev/test-story": "0.
|
|
60
|
+
"@shivaedev/access": "0.4.0",
|
|
61
|
+
"@shivaedev/admin": "0.19.0",
|
|
62
|
+
"@shivaedev/jobs": "0.31.0",
|
|
63
|
+
"@shivaedev/quality": "0.57.0",
|
|
64
|
+
"@shivaedev/rate-limit": "0.3.0",
|
|
65
|
+
"@shivaedev/test-sql": "0.17.0",
|
|
66
|
+
"@shivaedev/test-story": "0.35.0",
|
|
67
67
|
"@types/node": "24.19.2",
|
|
68
|
-
"better-auth": "1.7.
|
|
68
|
+
"better-auth": "1.7.14",
|
|
69
69
|
"effect": "4.0.6",
|
|
70
70
|
"pg-boss": "12.38.0",
|
|
71
71
|
"typescript": "7.0.2",
|
|
@@ -75,7 +75,9 @@
|
|
|
75
75
|
"@effect/platform-node": "4.0.6",
|
|
76
76
|
"@effect/sql-pg": "4.0.6",
|
|
77
77
|
"@effect/vitest": "4.0.6",
|
|
78
|
-
"
|
|
78
|
+
"@shivaedev/admin": "0.19.0",
|
|
79
|
+
"@shivaedev/test-sql": "0.17.0",
|
|
80
|
+
"better-auth": "1.7.14",
|
|
79
81
|
"effect": "4.0.6"
|
|
80
82
|
},
|
|
81
83
|
"peerDependenciesMeta": {
|
|
@@ -88,6 +90,12 @@
|
|
|
88
90
|
"@effect/vitest": {
|
|
89
91
|
"optional": true
|
|
90
92
|
},
|
|
93
|
+
"@shivaedev/admin": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"@shivaedev/test-sql": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
91
99
|
"better-auth": {
|
|
92
100
|
"optional": true
|
|
93
101
|
}
|
package/src/AppModule.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Layer, Pipeable } from "effect";
|
|
2
|
+
import type { RpcGroup } from "effect/rpc";
|
|
3
|
+
import type { AnyAdminRegistry } from "@shivaedev/admin/registry.ts";
|
|
4
|
+
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
5
|
+
|
|
6
|
+
export type ModuleLayer = Layer.Any & Pipeable.Pipeable;
|
|
7
|
+
export type ModuleAdmin = AnyAdminRegistry & { readonly handlers: ModuleLayer };
|
|
8
|
+
|
|
9
|
+
export interface AppModule {
|
|
10
|
+
readonly admin?: ModuleAdmin;
|
|
11
|
+
readonly group: RpcGroup.Any;
|
|
12
|
+
readonly handlers: ModuleLayer;
|
|
13
|
+
readonly migrations: Pick<MigrationOptions<unknown, unknown>, "loader" | "components">;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly ports?: ModuleLayer;
|
|
16
|
+
readonly queues?: readonly { readonly name: string }[];
|
|
17
|
+
readonly services: ModuleLayer;
|
|
18
|
+
readonly workers?: ModuleLayer;
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
export class DuplicateModuleQueue extends Schema.TaggedError<DuplicateModuleQueue>()("DuplicateModuleQueue", {
|
|
4
|
+
firstModule: Schema.String,
|
|
5
|
+
queue: Schema.String,
|
|
6
|
+
secondModule: Schema.String,
|
|
7
|
+
}) {
|
|
8
|
+
override get message() {
|
|
9
|
+
return `Queue "${this.queue}" is declared by both "${this.firstModule}" and "${this.secondModule}".`;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import type { Layer } from "effect";
|
|
3
3
|
import { Cause, Config, Context, Effect, Exit, ManagedRuntime } from "effect";
|
|
4
|
-
import type { PlatformRuntime, PlatformRuntimeOptions } from "
|
|
4
|
+
import type { PlatformRuntime, PlatformRuntimeOptions } from "#runtime/types.ts";
|
|
5
5
|
|
|
6
6
|
const RuntimeCacheKey = Symbol.for("@shivaedev/server/runtime-cache");
|
|
7
7
|
const sharedCache: unknown = Reflect.get(globalThis, RuntimeCacheKey);
|
|
@@ -8,6 +8,7 @@ export function nodeHttpServer(
|
|
|
8
8
|
readonly port?: number;
|
|
9
9
|
readonly gracefulShutdownTimeout?: Duration.Input;
|
|
10
10
|
readonly disablePreemptiveShutdown?: boolean;
|
|
11
|
+
readonly maxBodySize?: number;
|
|
11
12
|
},
|
|
12
13
|
) {
|
|
13
14
|
return Layer.unwrap(
|
|
@@ -17,8 +18,14 @@ export function nodeHttpServer(
|
|
|
17
18
|
gracefulShutdownTimeout: config?.gracefulShutdownTimeout,
|
|
18
19
|
host,
|
|
19
20
|
port,
|
|
21
|
+
websocket: config?.maxBodySize === undefined ? undefined : { maxPayload: socketPayloadLimit(config.maxBodySize) },
|
|
20
22
|
...(config?.disablePreemptiveShutdown === undefined ? {} : { disablePreemptiveShutdown: config.disablePreemptiveShutdown }),
|
|
21
23
|
});
|
|
22
24
|
}),
|
|
23
25
|
);
|
|
24
26
|
}
|
|
27
|
+
|
|
28
|
+
function socketPayloadLimit(bytes: number) {
|
|
29
|
+
// ws truncates maxPayload to a signed 32-bit integer; the RPC reader covers zero and larger limits.
|
|
30
|
+
return bytes > 0x7f_ff_ff_ff ? 0 : Math.max(1, bytes);
|
|
31
|
+
}
|
package/src/appDatabase.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import * as PgClient from "@effect/sql-pg/PgClient";
|
|
3
|
-
import { Clock, Config, Context, Duration, Effect, Fiber, Layer, Option, Redacted, Schedule } from "effect";
|
|
2
|
+
import { Clock, Config, Context, Crypto, Duration, Effect, Fiber, Layer, Option, Redacted, Schedule } from "effect";
|
|
3
|
+
import * as Hex from "effect/encoding/Hex";
|
|
4
4
|
import * as Reactivity from "effect/reactivity/Reactivity";
|
|
5
5
|
import { Migrator } from "effect/sql";
|
|
6
6
|
import { LiveServer } from "@shivaedev/contract/LiveServer.ts";
|
|
@@ -46,7 +46,7 @@ export function appDatabase<R, E = never>(options: AppDatabaseOptions<R, E>) {
|
|
|
46
46
|
const hints = yield* LiveServer;
|
|
47
47
|
const url = options.config?.databaseUrl ?? (yield* Config.Redacted("DATABASE_URL"));
|
|
48
48
|
const name = yield* Config.String("APP_NAME").pipe(Config.withDefault(new URL(Redacted.value(url)).pathname));
|
|
49
|
-
const channel = changes?.channel ??
|
|
49
|
+
const channel = changes?.channel ?? (yield* defaultChangesChannel(name));
|
|
50
50
|
const listenUrl = options.config?.listenDatabaseUrl ?? Option.getOrUndefined(yield* Config.Redacted("LISTEN_DATABASE_URL").pipe(Config.option));
|
|
51
51
|
const listenerClient =
|
|
52
52
|
listenUrl === undefined
|
|
@@ -74,6 +74,12 @@ export function appDatabase<R, E = never>(options: AppDatabaseOptions<R, E>) {
|
|
|
74
74
|
return worker.pipe(Layer.provideMerge(prepared));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
const defaultChangesChannel = Effect.fnUntraced(function* (name: string) {
|
|
78
|
+
const crypto = yield* Crypto.Crypto;
|
|
79
|
+
const digest = yield* crypto.digest("SHA-256", new TextEncoder().encode(name)).pipe(Effect.orDie);
|
|
80
|
+
return `changes_${Hex.encode(digest).slice(0, 32)}`;
|
|
81
|
+
});
|
|
82
|
+
|
|
77
83
|
function prepareMigrations<R, E>(migrations: AppDatabaseOptions<R, E>["migrations"]) {
|
|
78
84
|
switch (migrations.mode) {
|
|
79
85
|
case "check": {
|
package/src/appHost.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
2
|
-
import { Layer } from "effect";
|
|
2
|
+
import { Effect, Layer } from "effect";
|
|
3
3
|
import type { Rpc } from "effect/rpc";
|
|
4
|
+
import { schemaSensitiveKeys } from "@shivaedev/errors/schemaSensitiveKeys.ts";
|
|
5
|
+
import { isSensitiveKey } from "@shivaedev/errors/sensitive.ts";
|
|
4
6
|
import type { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
5
7
|
import type { AppHostFactory } from "#AppHostFactory.ts";
|
|
6
8
|
import type { AppHostInput, HostPreflight } from "#AppHostInput.ts";
|
|
@@ -8,6 +10,7 @@ import { appDatabase, type DatabaseConfig } from "#appDatabase.ts";
|
|
|
8
10
|
import { appHostHttp, deferredHost, migratedHost } from "#appHostHttp.ts";
|
|
9
11
|
import type { HostCoreOptions, HostPolicy, HostRouteRequirements, HostRoutes } from "#hostOptions.ts";
|
|
10
12
|
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
13
|
+
import { redactingDiagnostics } from "#redactingDiagnostics.ts";
|
|
11
14
|
|
|
12
15
|
export interface AppDatabaseOptions<R = never, E = never> {
|
|
13
16
|
readonly config?: DatabaseConfig;
|
|
@@ -114,16 +117,23 @@ export const appHost: AppHostFactory = <
|
|
|
114
117
|
TMigrationError
|
|
115
118
|
>,
|
|
116
119
|
) => {
|
|
120
|
+
const startup = options.preflight;
|
|
121
|
+
const preflight =
|
|
122
|
+
startup === undefined
|
|
123
|
+
? Layer.empty
|
|
124
|
+
: Layer.unwrap(
|
|
125
|
+
Effect.map(
|
|
126
|
+
"application" in options ? Effect.succeed(isSensitiveKey) : schemaSensitiveKeys(options.group, options.config?.sensitiveKeys),
|
|
127
|
+
(sensitive) => startup.pipe(Layer.provide(redactingDiagnostics(sensitive))),
|
|
128
|
+
),
|
|
129
|
+
);
|
|
117
130
|
if ("application" in options) {
|
|
118
|
-
return deferredHost(options.application, appDatabase(options)).pipe(
|
|
119
|
-
Layer.provideMerge(options.preflight ?? Layer.empty),
|
|
120
|
-
Layer.provide(NodeCrypto.layer),
|
|
121
|
-
);
|
|
131
|
+
return deferredHost(options.application, appDatabase(options)).pipe(Layer.provideMerge(preflight), Layer.provide(NodeCrypto.layer));
|
|
122
132
|
}
|
|
123
133
|
return options.migrations === undefined
|
|
124
|
-
? appHostHttp(options).pipe(Layer.provideMerge(
|
|
134
|
+
? appHostHttp(options).pipe(Layer.provideMerge(preflight), Layer.provide(NodeCrypto.layer))
|
|
125
135
|
: migratedHost({ ...options, migrations: options.migrations }, appDatabase({ ...options, migrations: options.migrations })).pipe(
|
|
126
|
-
Layer.provideMerge(
|
|
136
|
+
Layer.provideMerge(preflight),
|
|
127
137
|
Layer.provide(NodeCrypto.layer),
|
|
128
138
|
);
|
|
129
139
|
};
|
package/src/appHostHttp.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Effect, Layer } from "effect";
|
|
|
3
3
|
import { HttpRouter, HttpServer } from "effect/http";
|
|
4
4
|
import type { Rpc } from "effect/rpc";
|
|
5
5
|
import { schemaSensitiveKeys } from "@shivaedev/errors/schemaSensitiveKeys.ts";
|
|
6
|
+
import { nodeHttpServer } from "#adapters/nodeHttpServer.ts";
|
|
6
7
|
import type { appDatabase } from "#appDatabase.ts";
|
|
7
8
|
import type { AppHttpHostOptions } from "#appHost.ts";
|
|
8
9
|
import { browserErrorRoute } from "#browserErrorRoute.ts";
|
|
@@ -14,7 +15,6 @@ import { hostRpcRoutes } from "#hostRpcRoutes.ts";
|
|
|
14
15
|
import { hostTransport } from "#hostTransport.ts";
|
|
15
16
|
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
16
17
|
import { nativeClientOrigins } from "#nativeClientOrigins.ts";
|
|
17
|
-
import { nodeHttpServer } from "#nodeHttpServer.ts";
|
|
18
18
|
import { otlpTracing } from "#otlpTracing.ts";
|
|
19
19
|
import { RedactionPolicy } from "#RedactionPolicy.ts";
|
|
20
20
|
import { redactingDiagnostics } from "#redactingDiagnostics.ts";
|
|
@@ -53,7 +53,7 @@ export function appHostHttp<
|
|
|
53
53
|
const assets = options.assets === undefined ? Layer.empty : hostAssets(options.assets);
|
|
54
54
|
const application = Layer.mergeAll(options.services ?? Layer.empty);
|
|
55
55
|
const sessions = Layer.mergeAll(Layer.empty, ...(options.sessions === undefined ? [] : [options.sessions]));
|
|
56
|
-
const server = nodeHttpServer(host, options.config);
|
|
56
|
+
const server = nodeHttpServer(host, { ...options.config, maxBodySize: bodySize });
|
|
57
57
|
const applicationRoutes = hostApplicationRoutes(options.routes, bodySize);
|
|
58
58
|
const httpRoutes = Layer.mergeAll(
|
|
59
59
|
routes,
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import { RpcGroup } from "effect/rpc";
|
|
3
|
+
import type { Migrator } from "effect/sql";
|
|
4
|
+
import type { AdminPage } from "@shivaedev/admin/page.ts";
|
|
5
|
+
import type { AdminRegistry, AnyAdminRegistry } from "@shivaedev/admin/registry.ts";
|
|
6
|
+
import { mergeAdminRegistrations } from "@shivaedev/admin/server/mergeAdminRegistrations.ts";
|
|
7
|
+
import type { SchemaComponent } from "@shivaedev/sql/SchemaComponent.ts";
|
|
8
|
+
import type { AppModule, ModuleAdmin, ModuleLayer } from "#AppModule.ts";
|
|
9
|
+
import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
|
|
10
|
+
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
11
|
+
|
|
12
|
+
type ModuleField<TModules, TKey extends PropertyKey> = TModules extends unknown ? (TKey extends keyof TModules ? TModules[TKey] : never) : never;
|
|
13
|
+
type Layers<TModules extends readonly AppModule[], TKey extends "handlers" | "services" | "ports" | "workers"> = Extract<
|
|
14
|
+
ModuleField<TModules[number], TKey>,
|
|
15
|
+
Layer.Any
|
|
16
|
+
>;
|
|
17
|
+
type Admin<TModules extends readonly AppModule[]> = Extract<ModuleField<TModules[number], "admin">, ModuleAdmin>;
|
|
18
|
+
type Handlers<TModules extends readonly AppModule[]> = Layers<TModules, "handlers"> | Extract<ModuleField<Admin<TModules>, "handlers">, Layer.Any>;
|
|
19
|
+
type Pages<TModules extends readonly AppModule[]> = Extract<ModuleField<Admin<TModules>, "pages">, readonly AdminPage[]>;
|
|
20
|
+
type Queues<TModules extends readonly AppModule[]> = Extract<ModuleField<TModules[number], "queues">, readonly { readonly name: string }[]>[number];
|
|
21
|
+
type Ports<TModules extends readonly AppModule[]> = Layers<TModules, "ports">;
|
|
22
|
+
type Services<TModules extends readonly AppModule[]> = Layers<TModules, "services">;
|
|
23
|
+
type MigrationRequirements<TModules extends readonly AppModule[]> = Effect.Services<TModules[number]["migrations"]["loader"]>;
|
|
24
|
+
type Components<T> = T extends readonly (infer TComponent extends SchemaComponent<unknown, unknown>)[] ? TComponent : never;
|
|
25
|
+
type ModuleComponents<TModules extends AppModule> = Components<ModuleField<TModules["migrations"], "components">>;
|
|
26
|
+
|
|
27
|
+
export function appModules<const TModules extends readonly AppModule[], R = never, E = never, TRequirements = never>(
|
|
28
|
+
modules: TModules,
|
|
29
|
+
options?: { readonly replacements?: Layer.Layer<R, E, TRequirements> },
|
|
30
|
+
): Effect.Effect<
|
|
31
|
+
{
|
|
32
|
+
readonly workers: Layer.Layer<
|
|
33
|
+
Layer.Success<Layers<TModules, "workers">>,
|
|
34
|
+
Layer.Error<Layers<TModules, "workers">>,
|
|
35
|
+
Layer.Services<Layers<TModules, "workers">>
|
|
36
|
+
>;
|
|
37
|
+
readonly queues: readonly Queues<TModules>[];
|
|
38
|
+
readonly admin: AdminRegistry<readonly Pages<TModules>[number][]>;
|
|
39
|
+
readonly group: RpcGroup.RpcGroup<RpcGroup.Rpcs<TModules[number]["group"] | ModuleField<Admin<TModules>, "group">>>;
|
|
40
|
+
readonly handlers: Layer.Layer<Layer.Success<Handlers<TModules>>, Layer.Error<Handlers<TModules>>, Layer.Services<Handlers<TModules>>>;
|
|
41
|
+
readonly services: Layer.Layer<
|
|
42
|
+
Layer.Success<Services<TModules> | Ports<TModules>> | R,
|
|
43
|
+
Layer.Error<Services<TModules> | Ports<TModules>> | E,
|
|
44
|
+
Exclude<Layer.Services<Services<TModules>>, Layer.Success<Ports<TModules>> | R> | Layer.Services<Ports<TModules>> | TRequirements
|
|
45
|
+
>;
|
|
46
|
+
readonly migrations: {
|
|
47
|
+
readonly loader: Migrator.Loader<MigrationRequirements<TModules>>;
|
|
48
|
+
readonly components: readonly ModuleComponents<TModules[number]>[];
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
DuplicateModuleQueue
|
|
52
|
+
>;
|
|
53
|
+
export function appModules(
|
|
54
|
+
modules: readonly AppModule[],
|
|
55
|
+
options?: { readonly replacements?: ModuleLayer },
|
|
56
|
+
): Effect.Effect<
|
|
57
|
+
{
|
|
58
|
+
readonly workers: ModuleLayer;
|
|
59
|
+
readonly queues: readonly { readonly name: string }[];
|
|
60
|
+
readonly admin: AnyAdminRegistry;
|
|
61
|
+
readonly group: RpcGroup.Any;
|
|
62
|
+
readonly handlers: ModuleLayer;
|
|
63
|
+
readonly migrations: MigrationOptions<unknown, unknown>;
|
|
64
|
+
readonly services: ModuleLayer;
|
|
65
|
+
},
|
|
66
|
+
DuplicateModuleQueue
|
|
67
|
+
> {
|
|
68
|
+
return composeModules(modules, options);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const composeModules = Effect.fnUntraced(function* (modules: readonly AppModule[], options?: { readonly replacements?: ModuleLayer }) {
|
|
72
|
+
const owners = new Map<string, string>();
|
|
73
|
+
for (const module of modules) {
|
|
74
|
+
for (const queue of module.queues ?? []) {
|
|
75
|
+
const firstModule = owners.get(queue.name);
|
|
76
|
+
if (firstModule !== undefined) {
|
|
77
|
+
return yield* new DuplicateModuleQueue({ firstModule, queue: queue.name, secondModule: module.name });
|
|
78
|
+
}
|
|
79
|
+
owners.set(queue.name, module.name);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const queues = modules.flatMap((module) => module.queues ?? []);
|
|
83
|
+
const registrations = modules.flatMap((module) => (module.admin === undefined ? [] : [module.admin]));
|
|
84
|
+
const admin = mergeAdminRegistrations(...registrations);
|
|
85
|
+
const defaults = Layer.mergeAll(Layer.empty, ...modules.map((module) => module.ports ?? Layer.empty));
|
|
86
|
+
const ports = Layer.merge(defaults, options?.replacements ?? Layer.empty);
|
|
87
|
+
return {
|
|
88
|
+
admin,
|
|
89
|
+
group: RpcGroup.make().merge(...modules.map((module) => module.group), admin.group),
|
|
90
|
+
handlers: Layer.mergeAll(admin.handlers, ...modules.map((module) => module.handlers)),
|
|
91
|
+
migrations: {
|
|
92
|
+
components: modules.flatMap((module) => module.migrations.components ?? []),
|
|
93
|
+
loader: Effect.all(modules.map((module) => module.migrations.loader)).pipe(Effect.map((entries) => entries.flat())),
|
|
94
|
+
},
|
|
95
|
+
queues,
|
|
96
|
+
services: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.services)).pipe(Layer.provideMerge(ports)),
|
|
97
|
+
workers: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.workers ?? Layer.empty)),
|
|
98
|
+
};
|
|
99
|
+
});
|
package/src/boundedRpcRequest.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { HttpServerError,
|
|
2
|
+
import { HttpServerError, HttpServerRequest } from "effect/http";
|
|
3
3
|
import { readBoundedBody } from "@shivaedev/http/server/boundedBody.ts";
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
const
|
|
5
|
+
export const boundedRpcRequest = Effect.fnUntraced(function* () {
|
|
6
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
7
|
+
const arrayBuffer = yield* readBoundedBody().pipe(
|
|
8
|
+
Effect.provideService(HttpServerRequest.HttpServerRequest, request),
|
|
7
9
|
Effect.mapError((cause) =>
|
|
8
10
|
cause._tag === "RequestBodyTooLarge"
|
|
9
11
|
? new HttpServerError.HttpServerError({ reason: new HttpServerError.RequestParseError({ cause, request }) })
|
|
10
12
|
: cause,
|
|
11
13
|
),
|
|
12
14
|
Effect.cached,
|
|
13
|
-
Effect.runSync,
|
|
14
15
|
);
|
|
15
16
|
const text = Effect.map(arrayBuffer, (body) => new TextDecoder().decode(body));
|
|
16
17
|
// The native text reader destroys the HTTP socket on overflow, preventing a 4xx response.
|
|
@@ -25,4 +26,4 @@ export function boundedRpcRequest(request: HttpServerRequest.HttpServerRequest):
|
|
|
25
26
|
return Reflect.get(target, key, receiver);
|
|
26
27
|
},
|
|
27
28
|
});
|
|
28
|
-
}
|
|
29
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { HttpServerRequest } from "effect/http";
|
|
3
|
+
import * as Socket from "effect/socket/Socket";
|
|
4
|
+
|
|
5
|
+
export const boundedRpcSocket = Effect.fnUntraced(function* (limit: number) {
|
|
6
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
7
|
+
const upgrade = Effect.map(
|
|
8
|
+
request.upgrade,
|
|
9
|
+
(socket): Socket.Socket => ({
|
|
10
|
+
...socket,
|
|
11
|
+
reader: Effect.gen(function* () {
|
|
12
|
+
const reader = yield* socket.reader;
|
|
13
|
+
const writer = yield* socket.writer;
|
|
14
|
+
return {
|
|
15
|
+
...reader,
|
|
16
|
+
pull: Effect.flatMap(reader.pull, (frames) => {
|
|
17
|
+
if (frames.every((frame) => (typeof frame === "string" ? Buffer.byteLength(frame) : frame.byteLength) <= limit)) {
|
|
18
|
+
return Effect.succeed(frames);
|
|
19
|
+
}
|
|
20
|
+
const reason = new Socket.SocketCloseError({ closeReason: "RPC frame exceeds maxBodySize", code: 1009 });
|
|
21
|
+
return writer
|
|
22
|
+
.write(new Socket.CloseEvent(reason.code, reason.closeReason))
|
|
23
|
+
.pipe(Effect.andThen(Effect.fail(new Socket.SocketError({ reason }))));
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
return new Proxy(request, {
|
|
30
|
+
get: (target, key, receiver) => (key === "upgrade" ? upgrade : Reflect.get(target, key, receiver)),
|
|
31
|
+
});
|
|
32
|
+
});
|