@shivaedev/server 0.18.0 → 0.19.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 +12 -0
- package/README.md +55 -1
- 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/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/browserErrorRoute.js +1 -1
- package/dist/browserErrorRoute.js.map +1 -1
- package/dist/hostChanges.d.ts.map +1 -1
- package/dist/hostChanges.js +8 -11
- package/dist/hostChanges.js.map +1 -1
- package/dist/hostRpcRoutes.js +1 -1
- 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/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 +21 -0
- package/dist/testing/adapters/hostProcess.d.ts.map +1 -0
- package/dist/testing/adapters/hostProcess.js +81 -0
- package/dist/testing/adapters/hostProcess.js.map +1 -0
- package/dist/testing/hostProcess.d.ts +20 -0
- package/dist/testing/hostProcess.d.ts.map +1 -0
- package/dist/testing/hostProcess.js +31 -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 +16 -0
- package/dist/testing/hostProcessChild.js.map +1 -0
- package/dist/testing/hostProcessProtocol.d.ts +11 -0
- package/dist/testing/hostProcessProtocol.d.ts.map +1 -0
- package/dist/testing/hostProcessProtocol.js +4 -0
- package/dist/testing/hostProcessProtocol.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 +17 -12
- package/src/AppModule.ts +19 -0
- package/src/DuplicateModuleQueue.ts +11 -0
- package/src/appModules.ts +99 -0
- package/src/browserErrorRoute.ts +1 -1
- package/src/hostChanges.ts +8 -11
- package/src/hostRpcRoutes.ts +1 -1
- package/src/hostTransport.ts +1 -1
- package/src/nativeClientOrigins.ts +1 -1
- package/src/socketRpc.ts +1 -1
- package/src/testing/HostProcessError.ts +6 -0
- package/src/testing/adapters/hostProcess.ts +90 -0
- package/src/testing/hostProcess.ts +36 -0
- package/src/testing/hostProcessChild.ts +21 -0
- package/src/testing/hostProcessProtocol.ts +4 -0
- package/src/workerHost.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.0 - 2026-11-02
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Compose feature modules with `AppModule` and `appModules`, combining native RPC groups, handlers, migrations, services and admin registrations for `appHost`. Supply default ports separately so replacement Layers reach module services before they bind dependencies.
|
|
8
|
+
- The module entry point uses `@shivaedev/admin` as an optional peer; install it when composing modules.
|
|
9
|
+
- A scoped child-process host testing kit with IPC readiness and signal acknowledgements, health answers and response-header readouts.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Session-backed application hosts evaluate each live hint's read policy and pushed query against the current session, including changed roles and grants. Signing out, revocation and expiry still end subscriptions with `Unauthorized`.
|
|
14
|
+
|
|
3
15
|
## 0.18.0 - 2026-11-02
|
|
4
16
|
|
|
5
17
|
### Added
|
package/README.md
CHANGED
|
@@ -37,6 +37,28 @@ The optional modules solve different boundaries. `runtime/` carries Effect servi
|
|
|
37
37
|
|
|
38
38
|
`appHost` is the server entry point for an Effect app. For a PostgreSQL app, supply the native RPC group, handler and service Layers, migration loader, session policy and static asset directory. The host completes migrations before acquiring application services, starts Node HTTP with native Effect RPC over a WebSocket upgrade at `/rpc`, and provides SQL, Reactivity and `LiveServer` from `@shivaedev/contract/LiveServer.ts` to those Layers.
|
|
39
39
|
|
|
40
|
+
For feature modules, install the optional peer `@shivaedev/admin` and declare each registration with `satisfies AppModule` from `@shivaedev/server/AppModule.ts`. Each module supplies a diagnostic `name`, `group`, `handlers`, `services` and `migrations: { loader, components? }`. Keep default adapters in its optional `ports` Layer, put an optional `registerAdmin` result in `admin`, and declare owned `queues` and a `workers` Layer on the module. `jobModule` from `@shivaedev/jobs/server/jobModule.ts` supplies those two fields from a jobs registration list.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { Effect } from "effect";
|
|
44
|
+
import { appHost } from "@shivaedev/server/appHost.ts";
|
|
45
|
+
import { workerHost } from "@shivaedev/server/workerHost.ts";
|
|
46
|
+
import { appModules } from "@shivaedev/server/appModules.ts";
|
|
47
|
+
import { notes, tasks, sessions } from "./app.ts";
|
|
48
|
+
|
|
49
|
+
const hosts = Effect.gen(function* () {
|
|
50
|
+
const modules = yield* appModules([notes, tasks]);
|
|
51
|
+
return {
|
|
52
|
+
server: appHost({ ...modules, sessions }),
|
|
53
|
+
worker: workerHost({ ...modules, migrations: { ...modules.migrations, mode: "wait" } }),
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`appModules` returns an Effect that rejects duplicate queue names before building any host. `DuplicateModuleQueue` from `@shivaedev/server/DuplicateModuleQueue.ts` identifies `queue`, `firstModule` and `secondModule`; repeating a name within one module also fails. It combines the native RPC groups, handler Layers, migration loaders and schema components. It includes each admin registration's group and handlers and exposes their merged registry as `modules.admin`. Migration numbers belong to one application-wide sequence. Existing hosts can continue to supply their groups, handlers, services and migrations directly.
|
|
59
|
+
|
|
60
|
+
Pass `{ replacements: Layer.succeed(MyPort, implementation) }` as the second argument to `appModules`. Replacements take precedence over the combined default `ports` before module `services` acquire dependencies. Leave these ports unprovided in the module's service Layer; an adapter already captured by `Layer.provide` inside that Layer cannot be replaced from outside it. Missing ports and replacement Layer requirements remain in the host's requirement type. `workerHost` takes the same composition, provides its services to all module workers after database preparation, and scopes their lifetime to the returned Layer. Supply the shared `PgBoss` client through the service Layer in each process; the host and worker use the same module ports and replacements.
|
|
61
|
+
|
|
40
62
|
```ts
|
|
41
63
|
import { NodeRuntime } from "@effect/platform-node";
|
|
42
64
|
import { Layer } from "effect";
|
|
@@ -106,7 +128,7 @@ RPC request bodies are limited to 1 MiB by default. Set `MAX_BODY_SIZE` to a byt
|
|
|
106
128
|
|
|
107
129
|
For a native Node HTTP route outside RPC, read the request body with `readBoundedBody` from [`@shivaedev/http`](https://github.com/ShivaeDev/platform/tree/main/packages/http#readme), which rejects oversized bodies with a typed 413 failure.
|
|
108
130
|
|
|
109
|
-
Ordinary POST RPC uses `localRpcGuard` from `@shivaedev/identity/server/local.ts`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. The WebSocket upgrade uses the same loopback, origin and trusted-proxy checks without an HTTP body content type. Session lookup uses the upgrade's transport headers; RPC message headers cannot replace its cookie or Origin. Session middleware revalidates authenticated streams at `streamRevalidationInterval` and ends revoked subscriptions with typed `Unauthorized`. Cookie-authenticated sockets remain open; later protected calls use the same session checks. Automatic live subscriptions
|
|
131
|
+
Ordinary POST RPC uses `localRpcGuard` from `@shivaedev/identity/server/adapters/local.ts`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. The WebSocket upgrade uses the same loopback, origin and trusted-proxy checks without an HTTP body content type. Session lookup uses the upgrade's transport headers; RPC message headers cannot replace its cookie or Origin. Session middleware revalidates authenticated streams at `streamRevalidationInterval` and ends revoked subscriptions with typed `Unauthorized`. Cookie-authenticated sockets remain open; later protected calls use the same session checks. Automatic live subscriptions reload the session before each hint and use its current roles and grants for the query policy and any pushed query result. A policy denial keeps an established subscription open; delivery resumes on the next authorized hint. POST RPC refuses `$changes` subscriptions with the contract’s typed `WebSocketRequired` error and a message saying they need the WebSocket protocol. The host applies `RequestTracing` last to every served RPC, including loopback RPC, so it wraps authentication and handlers without a per-contract tracing declaration. Existing tracing declarations run once at that outermost boundary. With a session policy, contracts declare `Authenticated` and `MaybeAuthenticated` as needed; the host supplies their implementations. For `AuthenticatedUser`, merge `authenticatedUserLayer()` from `@shivaedev/identity/server/session.ts` beside the handlers. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
|
|
110
132
|
|
|
111
133
|
Native clients that cannot set upgrade headers use `makeClient`'s `bearerToken` option from `@shivaedev/contract/bind.ts`. On session hosts, `GET /rpc?auth=frame` requires a first text frame shaped as `{"_tag":"Authenticate","token":"<credential>"}` within five seconds, with at most 8192 characters. The host consumes that frame before starting native RPC and supplies its bearer as the socket's transport Authorization header. The existing session provider, identity middleware, Origin policy and query read policies apply to every call and live read. RPC message headers cannot replace the authenticated credential. Configure bearer admission on the session provider and the WebView Origin through `nativeOrigins`. A long-lived bearer is never placed in a URL.
|
|
112
134
|
|
|
@@ -352,6 +374,38 @@ export async function consumeSubscription(
|
|
|
352
374
|
|
|
353
375
|
The signal aborts on an additional signal, socket close, incomplete request close or an already destroyed connection. Normal completion of a request does not abort a continuing response. Without an explicit `nodeRequest`, the helper can read one from an srvx Web request's `runtime.node.req`. `dispose()` removes Node listeners and can be called repeatedly.
|
|
354
376
|
|
|
377
|
+
### Stories against a child host
|
|
378
|
+
|
|
379
|
+
`hostProcess(options)` from `@shivaedev/server/testing/hostProcess.ts` is a scoped kit for an application's real Node host process. It forks `options.module` with `args`, `cwd`, an explicit child environment in `env` and Node flags in `execArgv`. It waits for an IPC readiness message; stdout is ignored and stderr is inherited. Closing the owning Effect scope kills the child and waits for its exit. `stop()` does the same when a story needs to restart the host sooner.
|
|
380
|
+
|
|
381
|
+
In the child entry point, build the app host Layer, then run `reportHostReady` from `@shivaedev/server/testing/hostProcessChild.ts` with that Layer's context. It reads `HttpServer`, reports the listening URL and process ID over IPC, and fails if there is no parent IPC channel. The child must install its signal handlers before reporting readiness. After a handler finishes its work, run `acknowledgeHostSignal(signal)` from the same module. `signal(signal)` in the parent sends the OS signal and waits for that signal's IPC acknowledgement. Deliver signals sequentially, using signals the child handles; signals that kill or suspend a process cannot be acknowledged.
|
|
382
|
+
|
|
383
|
+
Wrap the kit in the application's story vocabulary:
|
|
384
|
+
|
|
385
|
+
```ts
|
|
386
|
+
import { expect } from "vitest";
|
|
387
|
+
import { storyKit } from "@shivaedev/test-story/server/storyKit.ts";
|
|
388
|
+
import { hostProcess } from "@shivaedev/server/testing/hostProcess.ts";
|
|
389
|
+
|
|
390
|
+
const host = storyKit({
|
|
391
|
+
name: "application host",
|
|
392
|
+
clock: "live",
|
|
393
|
+
stages: [],
|
|
394
|
+
create: () => hostProcess({ module: new URL("./host.ts", import.meta.url) }),
|
|
395
|
+
verbs: (process) => ({
|
|
396
|
+
health: process.health,
|
|
397
|
+
headers: process.headers,
|
|
398
|
+
reload: () => process.signal("SIGUSR2"),
|
|
399
|
+
}),
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
host.it("the running application answers health checks", [], function* ({ health }) {
|
|
403
|
+
expect(yield* health()).toMatchObject({ status: 200, body: "" });
|
|
404
|
+
});
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
`health()` requests `/health` and returns `{ status, body, headers }`. `headers(path)` returns the named path's response headers as a lowercase-keyed record. Both use real HTTP and leave redirects visible. The host's normal health semantics apply: reachable PostgreSQL produces 200; a host without a database produces 503. `url` and `pid` identify the ready child. Launch, signal and HTTP failures use the typed `HostProcessError` from `@shivaedev/server/testing/HostProcessError.ts`, with `operation` and the original `cause`. A child exit before readiness or signal acknowledgement fails the waiting action. A live child that never reports the expected message stays pending until its owning story is interrupted or times out.
|
|
408
|
+
|
|
355
409
|
### Low-memory PostgreSQL hosts
|
|
356
410
|
|
|
357
411
|
Use sql's [opt-in preset](https://github.com/ShivaeDev/platform/tree/main/packages/sql#low-memory-postgresql-hosts) with the host's ten-minute connection lifetime and one-minute idle timeout. The preset bounds PostgreSQL shared memory and per-operation work; connection recycling releases backend memory, and a page-cache trim releases clean file pages charged to the container. A busy workload still needs memory for its working set.
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
export type ModuleLayer = Layer.Any & Pipeable.Pipeable;
|
|
6
|
+
export type ModuleAdmin = AnyAdminRegistry & {
|
|
7
|
+
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 {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
}[];
|
|
19
|
+
readonly services: ModuleLayer;
|
|
20
|
+
readonly workers?: ModuleLayer;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=AppModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppModule.d.ts","sourceRoot":"","sources":["../src/AppModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;CAAE,CAAC;AAEhF,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC,CAAC;IACvF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppModule.js","sourceRoot":"","sources":["../src/AppModule.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare const DuplicateModuleQueue_base: Schema.Class<DuplicateModuleQueue, Schema.TaggedStruct<"DuplicateModuleQueue", {
|
|
3
|
+
readonly firstModule: Schema.String;
|
|
4
|
+
readonly queue: Schema.String;
|
|
5
|
+
readonly secondModule: Schema.String;
|
|
6
|
+
}>, import("effect/Cause").YieldableError>;
|
|
7
|
+
export declare class DuplicateModuleQueue extends DuplicateModuleQueue_base {
|
|
8
|
+
get message(): string;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=DuplicateModuleQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DuplicateModuleQueue.d.ts","sourceRoot":"","sources":["../src/DuplicateModuleQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;AAEhC,qBAAa,oBAAqB,SAAQ,yBAIxC;IACD,IAAa,OAAO,WAEnB;CACD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export class DuplicateModuleQueue extends Schema.TaggedError()("DuplicateModuleQueue", {
|
|
3
|
+
firstModule: Schema.String,
|
|
4
|
+
queue: Schema.String,
|
|
5
|
+
secondModule: Schema.String,
|
|
6
|
+
}) {
|
|
7
|
+
get message() {
|
|
8
|
+
return `Queue "${this.queue}" is declared by both "${this.firstModule}" and "${this.secondModule}".`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=DuplicateModuleQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DuplicateModuleQueue.js","sourceRoot":"","sources":["../src/DuplicateModuleQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAAC,sBAAsB,EAAE;IAC5G,WAAW,EAAE,MAAM,CAAC,MAAM;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,YAAY,EAAE,MAAM,CAAC,MAAM;CAC3B,CAAC;IACD,IAAa,OAAO;QACnB,OAAO,UAAU,IAAI,CAAC,KAAK,0BAA0B,IAAI,CAAC,WAAW,UAAU,IAAI,CAAC,YAAY,IAAI,CAAC;IACtG,CAAC;CACD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 } from "@shivaedev/admin/registry.ts";
|
|
6
|
+
import type { SchemaComponent } from "@shivaedev/sql/SchemaComponent.ts";
|
|
7
|
+
import type { AppModule, ModuleAdmin } from "#AppModule.ts";
|
|
8
|
+
import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
|
|
9
|
+
type ModuleField<TModules, TKey extends PropertyKey> = TModules extends unknown ? (TKey extends keyof TModules ? TModules[TKey] : never) : never;
|
|
10
|
+
type Layers<TModules extends readonly AppModule[], TKey extends "handlers" | "services" | "ports" | "workers"> = Extract<ModuleField<TModules[number], TKey>, Layer.Any>;
|
|
11
|
+
type Admin<TModules extends readonly AppModule[]> = Extract<ModuleField<TModules[number], "admin">, ModuleAdmin>;
|
|
12
|
+
type Handlers<TModules extends readonly AppModule[]> = Layers<TModules, "handlers"> | Extract<ModuleField<Admin<TModules>, "handlers">, Layer.Any>;
|
|
13
|
+
type Pages<TModules extends readonly AppModule[]> = Extract<ModuleField<Admin<TModules>, "pages">, readonly AdminPage[]>;
|
|
14
|
+
type Queues<TModules extends readonly AppModule[]> = Extract<ModuleField<TModules[number], "queues">, readonly {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
}[]>[number];
|
|
17
|
+
type Ports<TModules extends readonly AppModule[]> = Layers<TModules, "ports">;
|
|
18
|
+
type Services<TModules extends readonly AppModule[]> = Layers<TModules, "services">;
|
|
19
|
+
type MigrationRequirements<TModules extends readonly AppModule[]> = Effect.Services<TModules[number]["migrations"]["loader"]>;
|
|
20
|
+
type Components<T> = T extends readonly (infer TComponent extends SchemaComponent<unknown, unknown>)[] ? TComponent : never;
|
|
21
|
+
type ModuleComponents<TModules extends AppModule> = Components<ModuleField<TModules["migrations"], "components">>;
|
|
22
|
+
export declare function appModules<const TModules extends readonly AppModule[], R = never, E = never, TRequirements = never>(modules: TModules, options?: {
|
|
23
|
+
readonly replacements?: Layer.Layer<R, E, TRequirements>;
|
|
24
|
+
}): Effect.Effect<{
|
|
25
|
+
readonly workers: Layer.Layer<Layer.Success<Layers<TModules, "workers">>, Layer.Error<Layers<TModules, "workers">>, Layer.Services<Layers<TModules, "workers">>>;
|
|
26
|
+
readonly queues: readonly Queues<TModules>[];
|
|
27
|
+
readonly admin: AdminRegistry<readonly Pages<TModules>[number][]>;
|
|
28
|
+
readonly group: RpcGroup.RpcGroup<RpcGroup.Rpcs<TModules[number]["group"] | ModuleField<Admin<TModules>, "group">>>;
|
|
29
|
+
readonly handlers: Layer.Layer<Layer.Success<Handlers<TModules>>, Layer.Error<Handlers<TModules>>, Layer.Services<Handlers<TModules>>>;
|
|
30
|
+
readonly services: Layer.Layer<Layer.Success<Services<TModules> | Ports<TModules>> | R, Layer.Error<Services<TModules> | Ports<TModules>> | E, Exclude<Layer.Services<Services<TModules>>, Layer.Success<Ports<TModules>> | R> | Layer.Services<Ports<TModules>> | TRequirements>;
|
|
31
|
+
readonly migrations: {
|
|
32
|
+
readonly loader: Migrator.Loader<MigrationRequirements<TModules>>;
|
|
33
|
+
readonly components: readonly ModuleComponents<TModules[number]>[];
|
|
34
|
+
};
|
|
35
|
+
}, DuplicateModuleQueue>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=appModules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appModules.d.ts","sourceRoot":"","sources":["../src/appModules.ts"],"names":[],"mappings":"AAAA,OAAO,EA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D,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,EACrD,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,aAAa,CACjI,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE;QACpB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAClE,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;KACnE,CAAC;CACF,EACD,oBAAoB,CACpB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Effect, Layer } from "effect";
|
|
2
|
+
import { RpcGroup } from "effect/rpc";
|
|
3
|
+
import { mergeAdminRegistrations } from "@shivaedev/admin/server/mergeAdminRegistrations.ts";
|
|
4
|
+
import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
|
|
5
|
+
export function appModules(modules, options) {
|
|
6
|
+
return composeModules(modules, options);
|
|
7
|
+
}
|
|
8
|
+
const composeModules = Effect.fnUntraced(function* (modules, options) {
|
|
9
|
+
const owners = new Map();
|
|
10
|
+
for (const module of modules) {
|
|
11
|
+
for (const queue of module.queues ?? []) {
|
|
12
|
+
const firstModule = owners.get(queue.name);
|
|
13
|
+
if (firstModule !== undefined) {
|
|
14
|
+
return yield* new DuplicateModuleQueue({ firstModule, queue: queue.name, secondModule: module.name });
|
|
15
|
+
}
|
|
16
|
+
owners.set(queue.name, module.name);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const queues = modules.flatMap((module) => module.queues ?? []);
|
|
20
|
+
const registrations = modules.flatMap((module) => (module.admin === undefined ? [] : [module.admin]));
|
|
21
|
+
const admin = mergeAdminRegistrations(...registrations);
|
|
22
|
+
const defaults = Layer.mergeAll(Layer.empty, ...modules.map((module) => module.ports ?? Layer.empty));
|
|
23
|
+
const ports = Layer.merge(defaults, options?.replacements ?? Layer.empty);
|
|
24
|
+
return {
|
|
25
|
+
admin,
|
|
26
|
+
group: RpcGroup.make().merge(...modules.map((module) => module.group), admin.group),
|
|
27
|
+
handlers: Layer.mergeAll(admin.handlers, ...modules.map((module) => module.handlers)),
|
|
28
|
+
migrations: {
|
|
29
|
+
components: modules.flatMap((module) => module.migrations.components ?? []),
|
|
30
|
+
loader: Effect.all(modules.map((module) => module.migrations.loader)).pipe(Effect.map((entries) => entries.flat())),
|
|
31
|
+
},
|
|
32
|
+
queues,
|
|
33
|
+
services: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.services)).pipe(Layer.provideMerge(ports)),
|
|
34
|
+
workers: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.workers ?? Layer.empty)),
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=appModules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appModules.js","sourceRoot":"","sources":["../src/appModules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oDAAoD,CAAC;AAG7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA4ChE,MAAM,UAAU,UAAU,CACzB,OAA6B,EAC7B,OAAiD;IAajD,OAAO,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,Q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AC/F,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import * as HttpStatus from "effect/http/HttpStatus";
|
|
|
4
4
|
import { RateLimiter } from "effect/persistence";
|
|
5
5
|
import { redactBrowserText } from "@shivaedev/errors/redactBrowserText.ts";
|
|
6
6
|
import { isAuthUnavailable, isForbidden } from "@shivaedev/errors/taxonomy.ts";
|
|
7
|
-
import { localTransport, trustedProxyPeer } from "@shivaedev/identity/server/local.ts";
|
|
7
|
+
import { localTransport, trustedProxyPeer } from "@shivaedev/identity/server/adapters/local.ts";
|
|
8
8
|
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
9
9
|
import { resolveSession } from "@shivaedev/identity/server/session.ts";
|
|
10
10
|
const BrowserErrorReport = Schema.Struct({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserErrorRoute.js","sourceRoot":"","sources":["../src/browserErrorRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"browserErrorRoute.js","sourceRoot":"","sources":["../src/browserErrorRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,E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anges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAEhE,OAAO,EAAE,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAWhD,wBAAgB,WAAW,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;mBA2CH,GAAG,MAAM,WAAW;mBAG1F"}
|
package/dist/hostChanges.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Headers } from "effect/http";
|
|
|
3
3
|
import { Rpc } from "effect/rpc";
|
|
4
4
|
import { LiveServer } from "@shivaedev/contract/LiveServer.ts";
|
|
5
5
|
import { CurrentViewer } from "@shivaedev/contract/readPolicy.ts";
|
|
6
|
-
import {
|
|
6
|
+
import { currentSessionContext } from "@shivaedev/identity/server/currentSessionContext.ts";
|
|
7
7
|
import { recheckSession } from "@shivaedev/identity/server/recheckSession.ts";
|
|
8
8
|
import { revalidateStream } from "@shivaedev/identity/server/revalidateStream.ts";
|
|
9
9
|
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
@@ -19,11 +19,9 @@ export function hostChanges(group) {
|
|
|
19
19
|
return Stream.unwrap(Effect.gen(function* () {
|
|
20
20
|
const { subscription, context } = yield* resolveChanges(rpc, queries);
|
|
21
21
|
const viewer = yield* CurrentViewer;
|
|
22
|
-
const
|
|
23
|
-
? subscription.authorized
|
|
24
|
-
: authorizeSession(rpc._tag, viewer, subscription.authorized).pipe(Effect.provideService(SessionPolicy, sessions.value));
|
|
22
|
+
const refresh = refreshSession(sessions, viewer, rpc._tag);
|
|
25
23
|
const stream = Option.isSome(changes)
|
|
26
|
-
? Stream.unwrap(changes.value.subscribe({ ...subscription,
|
|
24
|
+
? Stream.unwrap(changes.value.subscribe({ ...subscription, refresh }, context, rerunQuery(group, options)))
|
|
27
25
|
: Stream.concat(Stream.succeed({ _tag: "Resync" }), Stream.never);
|
|
28
26
|
if (Option.isNone(sessions) || Option.isNone(viewer)) {
|
|
29
27
|
return stream;
|
|
@@ -50,11 +48,10 @@ export function hostChanges(group) {
|
|
|
50
48
|
return Context.makeUnsafe(handlers);
|
|
51
49
|
}));
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return yield* new Unauthorized({ message: "Authentication required" });
|
|
51
|
+
function refreshSession(sessions, viewer, tag) {
|
|
52
|
+
if (Option.isNone(sessions) || Option.isNone(viewer)) {
|
|
53
|
+
return Effect.context();
|
|
57
54
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
55
|
+
return currentSessionContext(viewer.value.id, recheckSession(Headers.empty, tag)).pipe(Effect.provideService(SessionPolicy, sessions.value));
|
|
56
|
+
}
|
|
60
57
|
//# sourceMappingURL=hostChanges.js.map
|
package/dist/hostChanges.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostChanges.js","sourceRoot":"","sources":["../src/hostChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAiB,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAe,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"hostChanges.js","sourceRoot":"","sources":["../src/hostChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAiB,MAA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jD,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACtD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAChC,SAAS;YACV,CAAC;YACD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE;gBACrB,OAAO,EAAE,QAAQ;gBACjB,OAAO,EAAE,CAAC,EAAE,OAAO,EAAmD,EAAE,OAAsD,EAAE,EAAE,CACjI,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC;gBACjC,GAAG,EAAE,GAAG,CAAC,IAAI;aACb,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,UAAU,CAAqE,QAAQ,CAAC,CAAC;IACzG,CAAC,CAAC,CACF,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,QAAqD,EAAE,MAA6B,EAAE,GAAW;IACxH,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACtD,OAAO,MAAM,CAAC,OAAO,EAAS,CAAC;IAChC,CAAC;IACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9I,CAAC"}
|
package/dist/hostRpcRoutes.js
CHANGED
|
@@ -3,7 +3,7 @@ import { HttpEffect, HttpIncomingMessage, HttpRouter, HttpServerRequest, HttpSer
|
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { RpcSerialization } from "effect/rpc";
|
|
5
5
|
import { validateReadPolicies } from "@shivaedev/contract/validateReadPolicies.ts";
|
|
6
|
-
import { localRpcGuard } from "@shivaedev/identity/server/local.ts";
|
|
6
|
+
import { localRpcGuard } from "@shivaedev/identity/server/adapters/local.ts";
|
|
7
7
|
import { authenticatedLayer, maybeAuthenticatedLayer } from "@shivaedev/identity/server/session.ts";
|
|
8
8
|
import { boundedRpcRequest } from "#boundedRpcRequest.ts";
|
|
9
9
|
import { hostChanges } from "#hostChanges.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostRpcRoutes.js","sourceRoot":"","sources":["../src/hostRpcRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAA2B,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"hostRpcRoutes.js","sourceRoot":"","sources":["../src/hostRpcRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAA2B,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAE7E,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,M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ACD,CAAC;IACH,CAAC,CAAC,CACF,CAAC,IAAI,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAC7G,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAC3C,CAAC;AACH,CAAC"}
|
package/dist/hostTransport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config, Effect, Option, Result, Schema } from "effect";
|
|
2
2
|
import * as NetAddress from "effect/net/NetAddress";
|
|
3
|
-
import { TrustedProxy } from "@shivaedev/identity/server/trustedProxy.ts";
|
|
3
|
+
import { TrustedProxy } from "@shivaedev/identity/server/adapters/trustedProxy.ts";
|
|
4
4
|
import { NativeOrigins } from "#nativeClientOrigins.ts";
|
|
5
5
|
import { TrustedProxyRequired } from "#TrustedProxyRequired.ts";
|
|
6
6
|
export const hostTransport = Effect.fn("Platform.hostTransport")(function* (options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostTransport.js","sourceRoot":"","sources":["../src/hostTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"hostTransport.js","sourceRoot":"","sources":["../src/hostTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,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from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
|
-
import { localTransport } from "@shivaedev/identity/server/local.ts";
|
|
4
|
+
import { localTransport } from "@shivaedev/identity/server/adapters/local.ts";
|
|
5
5
|
export const NativeOrigins = Schema.Array(Schema.String.check(Schema.makeFilter((origin) => {
|
|
6
6
|
try {
|
|
7
7
|
const url = new URL(origin);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeClientOrigins.js","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzG,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"nativeClientOrigins.js","sourceRoot":"","sources":["../src/nativeClientOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzG,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CACxC,MAAM,CAAC,MAAM,CAAC,KAAK,CAClB,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE;IAC5B,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,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QACnB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC,iBAAiB,CAAC;QAC3D,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACnD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1E,OAAO,kBAAkB,CAAC,IAAI,CAAC,iCAAiC,EAAE;gBACjE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC;aAC3C,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;YACrD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC;QACtB,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC7B,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;SAClD,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;IACrG,CAAC,CAAC,CACF,CAAC,KAAK,CAAC;AACT,CAAC"}
|
package/dist/socketRpc.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Effect } from "effect";
|
|
|
2
2
|
import { Headers, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { isAuthUnavailable, isForbidden } from "@shivaedev/errors/taxonomy.ts";
|
|
5
|
-
import { localTransport } from "@shivaedev/identity/server/local.ts";
|
|
5
|
+
import { localTransport } from "@shivaedev/identity/server/adapters/local.ts";
|
|
6
6
|
import { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
7
7
|
import { resolveSession } from "@shivaedev/identity/server/session.ts";
|
|
8
8
|
import { makeSocketSession, SocketSession } from "@shivaedev/identity/server/socketSession.ts";
|
package/dist/socketRpc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketRpc.js","sourceRoot":"","sources":["../src/socketRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"socketRpc.js","sourceRoot":"","sources":["../src/socketRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MA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AAS,eAAe;IACvB,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3G,CAAC;AACD,SAAS,SAAS;IACjB,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;AAClG,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const HostProcessError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
2
|
+
readonly _tag: "HostProcessError";
|
|
3
|
+
} & Readonly<A>;
|
|
4
|
+
export declare class HostProcessError extends HostProcessError_base<{
|
|
5
|
+
readonly operation: "launch" | "signal" | "request";
|
|
6
|
+
readonly cause: unknown;
|
|
7
|
+
}> {
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=HostProcessError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HostProcessError.d.ts","sourceRoot":"","sources":["../../src/testing/HostProcessError.ts"],"names":[],"mappings":";;;AAEA,qBAAa,gBAAiB,SAAQ,sBAAqC;IAC1E,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB,CAAC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HostProcessError.js","sourceRoot":"","sources":["../../src/testing/HostProcessError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAGvE;CAAG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
export interface HostProcessOptions {
|
|
4
|
+
readonly args?: readonly string[];
|
|
5
|
+
readonly cwd?: string;
|
|
6
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
7
|
+
readonly execArgv?: readonly string[];
|
|
8
|
+
readonly module: string | URL;
|
|
9
|
+
}
|
|
10
|
+
export declare function forkHost(options: HostProcessOptions): ChildProcess;
|
|
11
|
+
export declare function receiveHostMessage<A>(child: ChildProcess, schema: Schema.Codec<A>, signal: AbortSignal, action?: () => void): Promise<A>;
|
|
12
|
+
export declare function stopHost(child: ChildProcess): Promise<void>;
|
|
13
|
+
export declare function sendHostMessage(message: unknown): Promise<void>;
|
|
14
|
+
export declare function hostResponse(url: string, path: string, signal: AbortSignal): Promise<{
|
|
15
|
+
body: string;
|
|
16
|
+
headers: {
|
|
17
|
+
[k: string]: string;
|
|
18
|
+
};
|
|
19
|
+
status: number;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=hostProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostProcess.d.ts","sourceRoot":"","sources":["../../../src/testing/adapters/hostProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAG/E,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC;CAC9B;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,gBAQnD;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,IAAI,cAyC3H;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,iBAQ3C;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,iBAQ/C;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW;;;;;;GAGhF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { fork } from "node:child_process";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { Option, Schema } from "effect";
|
|
5
|
+
export function forkHost(options) {
|
|
6
|
+
const settings = {
|
|
7
|
+
cwd: options.cwd,
|
|
8
|
+
env: options.env,
|
|
9
|
+
execArgv: [...(options.execArgv ?? [])],
|
|
10
|
+
stdio: ["ignore", "ignore", "inherit", "ipc"],
|
|
11
|
+
};
|
|
12
|
+
return fork(typeof options.module === "string" ? options.module : fileURLToPath(options.module), [...(options.args ?? [])], settings);
|
|
13
|
+
}
|
|
14
|
+
export function receiveHostMessage(child, schema, signal, action) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
function cleanup() {
|
|
17
|
+
child.off("message", message);
|
|
18
|
+
child.off("exit", exited);
|
|
19
|
+
child.off("error", failed);
|
|
20
|
+
signal.removeEventListener("abort", aborted);
|
|
21
|
+
}
|
|
22
|
+
function failed(cause) {
|
|
23
|
+
cleanup();
|
|
24
|
+
reject(cause);
|
|
25
|
+
}
|
|
26
|
+
function exited(code, delivered) {
|
|
27
|
+
failed(new Error(`Host exited (${delivered ?? code}) before IPC acknowledgement`));
|
|
28
|
+
}
|
|
29
|
+
function aborted() {
|
|
30
|
+
failed(signal.reason);
|
|
31
|
+
}
|
|
32
|
+
function message(value) {
|
|
33
|
+
const decoded = Schema.decodeUnknownOption(schema)(value);
|
|
34
|
+
if (Option.isSome(decoded)) {
|
|
35
|
+
cleanup();
|
|
36
|
+
resolve(decoded.value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
child.on("message", message);
|
|
40
|
+
child.once("exit", exited);
|
|
41
|
+
child.once("error", failed);
|
|
42
|
+
signal.addEventListener("abort", aborted, { once: true });
|
|
43
|
+
if (signal.aborted) {
|
|
44
|
+
aborted();
|
|
45
|
+
}
|
|
46
|
+
else if (child.exitCode !== null || child.signalCode !== null) {
|
|
47
|
+
exited(child.exitCode, child.signalCode);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
try {
|
|
51
|
+
action?.();
|
|
52
|
+
}
|
|
53
|
+
catch (cause) {
|
|
54
|
+
failed(cause);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export function stopHost(child) {
|
|
60
|
+
if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null) {
|
|
61
|
+
return Promise.resolve();
|
|
62
|
+
}
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
child.once("exit", () => resolve());
|
|
65
|
+
child.kill("SIGKILL");
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export function sendHostMessage(message) {
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
if (process.send === undefined) {
|
|
71
|
+
reject(new Error("Host process needs a parent IPC channel"));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
process.send(message, (error) => (error === null ? resolve() : reject(error)));
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export async function hostResponse(url, path, signal) {
|
|
78
|
+
const response = await fetch(new URL(path, url), { redirect: "manual", signal });
|
|
79
|
+
return { body: await response.text(), headers: Object.fromEntries(response.headers), status: response.status };
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=hostProcess.js.map
|