@shivaedev/server 0.45.0 → 0.46.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.46.0 - 2026-11-21
4
+
5
+ ### Added
6
+
7
+ - `AppModule` takes a third form for a registration that serves no RPCs, with no `group`, `handlers` or `module`. It carries any of `admin`, `ports`, `queues`, `workers`, `migrations`, `requestServices` and `services` and an optional `name`, so a registration with only admin pages, queues or workers writes `{ admin } satisfies AppModule` instead of `group: RpcGroup.make(), handlers: Layer.empty, name: "…"`.
8
+ - `services` is optional in every form of `AppModule`, and a registration without it composes as `Layer.empty`. `appModules` still refuses a defined module whose operations yield a service no registration provides.
9
+
10
+ ### Breaking
11
+
12
+ - `DuplicateModuleQueue`'s `firstModule` and `secondModule` are `undefined` for a registration without a name, and the new `firstAdminPage` and `secondAdminPage` hold such a registration's first admin page id; they stay `undefined` for a named registration. Its message names that registration by the page, or says it has no name and to give it one. Code that reads `firstModule` or `secondModule` as a `string` handles `undefined`, or reads the message.
13
+
3
14
  ## 0.45.0 - 2026-11-21
4
15
 
5
16
  ### Fixed
package/README.md CHANGED
@@ -84,7 +84,7 @@ Host option types include this HTTP-only shape. A wrapper that reads native RPC
84
84
 
85
85
  `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/live-server/service.ts` to those Layers.
86
86
 
87
- For feature modules, install the optional peer `@shivaedev/admin` and declare each registration with `satisfies AppModule` from `@shivaedev/server/AppModule.ts`. Each module supplies its operations, `services` and, when it owns tables, `migrations: { loader, components? }`; a module without migrations leaves the field out. A defined module takes its name from the module itself and its registration gives none, so the two cannot disagree; a `group` plus `handlers` registration supplies a `name`, because nothing else names it. `migrationsIn(directory)` from `@shivaedev/server/migrationsIn.ts` takes the folder that contains `migrations`, the same argument as `loadMigrationsIn` from `@shivaedev/sql/loadMigrationsIn.ts`, and returns `{ loader }` for the `migrations` folder in it, found by `loadMigrationsIn` under Node's `NodeServices.layer`, so a registration beside its `migrations` folder writes `migrations: migrationsIn(import.meta.dirname)` and needs the optional peer `@effect/platform-node`. Register caller-dependent Layers in the optional `requestServices` slot beside global `services`. 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.
87
+ For feature modules, install the optional peer `@shivaedev/admin` and declare each registration with `satisfies AppModule` from `@shivaedev/server/AppModule.ts`. A registration takes one of three forms. A defined module registers as `module:` and takes its name from the module itself, so its registration gives none that could disagree. An RPC group served by hand-written handlers registers as `group` plus `handlers` plus a `name`, because nothing else names it. A registration that serves no RPCs, such as an application's foundation or a registration with only admin pages, ports, queues or workers, names neither and may give a `name`. Every form lists only what it contributes: `services` when it has a service Layer of its own, and `migrations: { loader, components? }` when it owns tables; a registration without either leaves the field out. `migrationsIn(directory)` from `@shivaedev/server/migrationsIn.ts` takes the folder that contains `migrations`, the same argument as `loadMigrationsIn` from `@shivaedev/sql/loadMigrationsIn.ts`, and returns `{ loader }` for the `migrations` folder in it, found by `loadMigrationsIn` under Node's `NodeServices.layer`, so a registration beside its `migrations` folder writes `migrations: migrationsIn(import.meta.dirname)` and needs the optional peer `@effect/platform-node`. Register caller-dependent Layers in the optional `requestServices` slot beside global `services`. 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.
88
88
 
89
89
  ```ts
90
90
  import { Effect } from "effect";
@@ -104,27 +104,30 @@ const hosts = Effect.gen(function* () {
104
104
 
105
105
  An application built with [`@shivaedev/build`](https://github.com/ShivaeDev/platform/tree/main/packages/build#the-servers-module-list) writes no such list: its generator finds every exported registration written `satisfies AppModule` and writes them to `src/generated/server/modules.ts` in the order of their files' paths, and the application passes that list to `appModules` beside the registrations that are not module folders, such as its foundation, so a module is registered by creating its folder. Admin navigation and the order in which `appModules` composes Layers follow the list. What the merged Layers provide and the migrations do not depend on it, because migrations run by their number. An application that needs another order renames a module's folder, or composes that registration beside its foundation where the generator does not find it, such as a function that returns it.
106
106
 
107
- A module defined with `defineModule` from `@shivaedev/contract/defineModule.ts` registers as `module:`, and the host builds its group and its handlers with `moduleHandlers`. Its handlers need the services its operations' `run` and read policies yield, less what its middleware and subject provide per call; the registration's `services` and `ports` provide them, except the SQL client and the other services the host provides. An RPC group that is not a defined module, such as a contract served by hand-written handlers, registers as `group` plus `handlers` instead, and both kinds sit in one application's module list:
107
+ A module defined with `defineModule` from `@shivaedev/contract/defineModule.ts` registers as `module:`, and the host builds its group and its handlers with `moduleHandlers`. Its handlers need the services its operations' `run` and read policies yield, less what its middleware and subject provide per call; the registration's `services` and `ports` provide them, except the SQL client and the other services the host provides. An RPC group that is not a defined module, such as a contract served by hand-written handlers, registers as `group` plus `handlers` instead. A registration that only brings an admin page writes just `admin`, and all three sit in one application's module list:
108
108
 
109
109
  ```ts
110
- import { Layer } from "effect";
110
+ import { adminRegistry } from "@shivaedev/admin/registry.ts";
111
+ import { registerAdmin } from "@shivaedev/admin/server/registerAdmin.ts";
111
112
  import { defineModule } from "@shivaedev/contract/defineModule.ts";
112
113
  import { migrationsIn } from "@shivaedev/server/migrationsIn.ts";
113
114
  import type { AppModule } from "@shivaedev/server/AppModule.ts";
114
115
  import { notesWire } from "#generated/modules/notes/Notes.ts";
115
116
  import { Create, Get } from "./notes/operations.ts";
116
117
  import { Drafts, readDraft } from "./drafts.ts";
118
+ import { Usage, UsagePage } from "./usage.ts";
117
119
 
118
120
  export const Notes = defineModule({ name: "notes", operations: [Create, Get], wire: notesWire });
119
121
 
120
- export const notes = { migrations: migrationsIn(import.meta.dirname), module: Notes, services: Layer.empty } satisfies AppModule;
122
+ export const notes = { migrations: migrationsIn(import.meta.dirname), module: Notes } satisfies AppModule;
121
123
 
122
124
  export const drafts = {
123
125
  group: Drafts,
124
126
  handlers: Drafts.application.toLayer({ "drafts.read": readDraft }),
125
127
  name: "drafts",
126
- services: Layer.empty,
127
128
  } satisfies AppModule;
129
+
130
+ export const usage = { admin: registerAdmin(adminRegistry(UsagePage), { usage: Usage }) } satisfies AppModule;
128
131
  ```
129
132
 
130
133
  A defined module's generated handlers check each query's read policy with the module's services. Hand-written handlers would move that check to the host's read-policy guard, in the handlers' own context, so a defined module would have two paths. `AppModule` refuses a defined module as `group` at compile time, and the host refuses to start when any query of a defined module is served by another handler: it fails with `HandWrittenModuleHandlers` from `@shivaedev/server/HandWrittenModuleHandlers.ts`, whose `module`, `queries` and `message` name the module, each affected query and the `module:` registration to use instead. Fakes in this repository's own stories opt out through `replacedModuleHandlers` in the package's test support, which is not published.
@@ -138,7 +141,7 @@ src/test-support/compiler-fixtures/unprovidedService.ts(26,12): error TS2345: Ar
138
141
 
139
142
  A service may come from another registration in the same list. The `replacements` Layer only overrides default ports, so a service that only the replacements provide is refused too: give it a default in a registration's `ports`. A service the application provides around the host instead belongs in a registration. The check reads each module's services from its registration's own type, so it refuses a registration typed as `AppModule`, returned by a helper typed that way, or whose `module` is typed as `RegisteredModule`: that type has lost the services the module's handlers need. A `group` plus `handlers` registration typed as `AppModule` is refused too, because its type is the same. Declare the registration with `satisfies AppModule` instead.
140
143
 
141
- `appModules` returns an Effect that rejects duplicate queue names before building any host. `DuplicateModuleQueue` from `@shivaedev/server/DuplicateModuleQueue.ts` identifies `queue`, `firstModule` and `secondModule`, naming a defined module by its own name; repeating a name within one module also fails. It combines the native RPC groups, handler Layers, the migration loaders and schema components of the modules that declare `migrations`, skipping the rest. 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.
144
+ `appModules` returns an Effect that rejects duplicate queue names before building any host. `DuplicateModuleQueue` from `@shivaedev/server/DuplicateModuleQueue.ts` identifies `queue`, `firstModule` and `secondModule`, naming a defined module by its own name, and `firstAdminPage` and `secondAdminPage`, the first admin page id of a registration without a name. Its message names a registration without a name by that page, or else says it has no name and to give it one. Repeating a name within one registration also fails. It combines the native RPC groups, handler Layers, the migration loaders and schema components of the modules that declare `migrations`, skipping the rest. 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.
142
145
 
143
146
  The host builds `services` once for its lifetime and builds `requestServices` once per RPC call, including each call on a persistent WebSocket connection. Native RPC middleware supplies the request services after the identity middleware of the module or contract resolves the caller. Declare `selfSubject` or `accountSubject` on contracts whose request services require `Subject`, `SessionUser` and `Identity`. Request services yield global dependencies from the enclosing environment; leave those global Layers out of the request Layer so they are reused. `appModules` rejects global services that require caller context or a service registered in the request slot.
144
147
 
@@ -16,7 +16,7 @@ interface ModuleParts {
16
16
  readonly name: string;
17
17
  }[];
18
18
  readonly requestServices?: Layer.Layer<never, never, unknown>;
19
- readonly services: ModuleLayer;
19
+ readonly services?: ModuleLayer;
20
20
  readonly workers?: ModuleLayer;
21
21
  }
22
22
  export type AppModule = (ModuleParts & {
@@ -31,6 +31,11 @@ export type AppModule = (ModuleParts & {
31
31
  readonly handlers?: never;
32
32
  readonly module: RegisteredModule;
33
33
  readonly name?: never;
34
+ }) | (ModuleParts & {
35
+ readonly group?: never;
36
+ readonly handlers?: never;
37
+ readonly module?: never;
38
+ readonly name?: string;
34
39
  });
35
40
  export type RegisteredModule = RpcGroup.Any & Pick<AnyModule, "application" | "declaration"> & {
36
41
  readonly "~requires": unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"AppModule.d.ts","sourceRoot":"","sources":["../src/AppModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,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AAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAG1H,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,CAAC,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import { Schema } from "effect";
2
2
  declare const DuplicateModuleQueue_base: Schema.Class<DuplicateModuleQueue, Schema.TaggedStruct<"DuplicateModuleQueue", {
3
- readonly firstModule: Schema.String;
3
+ readonly firstAdminPage: Schema.optional<Schema.String>;
4
+ readonly firstModule: Schema.optional<Schema.String>;
4
5
  readonly queue: Schema.String;
5
- readonly secondModule: Schema.String;
6
+ readonly secondAdminPage: Schema.optional<Schema.String>;
7
+ readonly secondModule: Schema.optional<Schema.String>;
6
8
  }>, import("effect/Cause").YieldableError>;
7
9
  export declare class DuplicateModuleQueue extends DuplicateModuleQueue_base {
8
10
  get message(): string;
@@ -1 +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"}
1
+ {"version":3,"file":"DuplicateModuleQueue.d.ts","sourceRoot":"","sources":["../src/DuplicateModuleQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;;AAUhC,qBAAa,oBAAqB,SAAQ,yBAMxC;IACD,IAAa,OAAO,WAOnB;CACD"}
@@ -1,11 +1,25 @@
1
1
  import { Schema } from "effect";
2
+ function owner(name, adminPage) {
3
+ if (name !== undefined) {
4
+ return `"${name}"`;
5
+ }
6
+ return adminPage === undefined ? "a registration with no name" : `the registration of admin page "${adminPage}"`;
7
+ }
8
+ // A registration without a name is found by its first admin page, and one with neither is only described.
2
9
  export class DuplicateModuleQueue extends Schema.TaggedError()("DuplicateModuleQueue", {
3
- firstModule: Schema.String,
10
+ firstAdminPage: Schema.optional(Schema.String),
11
+ firstModule: Schema.optional(Schema.String),
4
12
  queue: Schema.String,
5
- secondModule: Schema.String,
13
+ secondAdminPage: Schema.optional(Schema.String),
14
+ secondModule: Schema.optional(Schema.String),
6
15
  }) {
7
16
  get message() {
8
- return `Queue "${this.queue}" is declared by both "${this.firstModule}" and "${this.secondModule}".`;
17
+ const first = owner(this.firstModule, this.firstAdminPage);
18
+ const second = owner(this.secondModule, this.secondAdminPage);
19
+ const unfound = [first, second].includes("a registration with no name")
20
+ ? " Give the registration with no name a `name` so this message can name it."
21
+ : "";
22
+ return `Queue "${this.queue}" is declared by both ${first} and ${second}.${unfound}`;
9
23
  }
10
24
  }
11
25
  //# sourceMappingURL=DuplicateModuleQueue.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"DuplicateModuleQueue.js","sourceRoot":"","sources":["../src/DuplicateModuleQueue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,SAAS,KAAK,CAAC,IAAwB,EAAE,SAA6B;IACrE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,IAAI,IAAI,GAAG,CAAC;IACpB,CAAC;IACD,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,mCAAmC,SAAS,GAAG,CAAC;AAClH,CAAC;AAED,0GAA0G;AAC1G,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAAC,sBAAsB,EAAE;IAC5G,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,eAAe,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC/C,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CAC5C,CAAC;IACD,IAAa,OAAO;QACnB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3D,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;YACtE,CAAC,CAAC,2EAA2E;YAC7E,CAAC,CAAC,EAAE,CAAC;QACN,OAAO,UAAU,IAAI,CAAC,KAAK,yBAAyB,KAAK,QAAQ,MAAM,IAAI,OAAO,EAAE,CAAC;IACtF,CAAC;CACD"}
@@ -6,7 +6,7 @@ import type { AdminRegistry } from "@shivaedev/admin/registry.ts";
6
6
  import { type AnyModule, type ModuleHandlers } from "@shivaedev/contract/moduleHandlers.ts";
7
7
  import type { SchemaComponent } from "@shivaedev/sql/SchemaComponent.ts";
8
8
  import type { AppModule, ModuleAdmin } from "#AppModule.ts";
9
- import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
9
+ import type { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
10
10
  import type { ProvidedModules } from "#providedModules.ts";
11
11
  import type { GlobalServices } from "#requestServices.ts";
12
12
  type ModuleField<TModules, TKey extends PropertyKey> = TModules extends unknown ? (TKey extends keyof TModules ? TModules[TKey] : never) : never;
@@ -1 +1 @@
1
- {"version":3,"file":"appModules.d.ts","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;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,8BAA8B,CAAC;AAEpF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAkB,MAAM,uCAAuC,CAAC;AAC5G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,KAAK,WAAW,CAAC,QAAQ,EAAE,IAAI,SAAS,WAAW,IAAI,QAAQ,SAAS,OAAO,GAAG,CAAC,IAAI,SAAS,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AACjJ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AC,EAClD,KAAK,EACL,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CACnD,CAAC;IACF,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC7B,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,EACvD,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,EAAE,CAAC;KAC3D,CAAC;CACF,EACD,oBAAoB,CACpB,CAAC"}
@@ -2,44 +2,41 @@ import { Effect, Layer } from "effect";
2
2
  import { RpcGroup } from "effect/rpc";
3
3
  import { mergeAdminRegistrations } from "@shivaedev/admin/server/mergeAdminRegistrations.ts";
4
4
  import { moduleHandlers } from "@shivaedev/contract/moduleHandlers.ts";
5
- import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
5
+ import { moduleQueues } from "#moduleQueues.ts";
6
6
  export function appModules(modules, options) {
7
7
  return composeModules(modules, options);
8
8
  }
9
9
  const composeModules = Effect.fnUntraced(function* (modules, options) {
10
- const owners = new Map();
11
- for (const module of modules) {
12
- for (const queue of module.queues ?? []) {
13
- const firstModule = owners.get(queue.name);
14
- if (firstModule !== undefined) {
15
- return yield* new DuplicateModuleQueue({ firstModule, queue: queue.name, secondModule: moduleName(module) });
16
- }
17
- owners.set(queue.name, moduleName(module));
18
- }
19
- }
20
- const queues = modules.flatMap((module) => module.queues ?? []);
10
+ const queues = yield* moduleQueues(modules);
21
11
  const registrations = modules.flatMap((module) => (module.admin === undefined ? [] : [module.admin]));
22
12
  const admin = mergeAdminRegistrations(...registrations);
23
13
  const defaults = Layer.mergeAll(Layer.empty, ...modules.map((module) => module.ports ?? Layer.empty));
24
14
  const ports = Layer.merge(defaults, options?.replacements ?? Layer.empty);
25
15
  return {
26
16
  admin,
27
- group: RpcGroup.make().merge(...modules.map((module) => (module.module === undefined ? module.group : module.module)), admin.group),
28
- // The overload types each module's handlers from its operations' services; at run time moduleHandlers reads only its operations.
29
- handlers: Layer.mergeAll(admin.handlers, ...modules.map((module) => module.module === undefined
30
- ? module.handlers
31
- : moduleHandlers({ "~requires": {}, application: module.module.application, declaration: module.module.declaration }))),
17
+ group: RpcGroup.make().merge(...modules.flatMap(servedGroup), admin.group),
18
+ handlers: Layer.mergeAll(admin.handlers, ...modules.flatMap(servedHandlers)),
32
19
  migrations: {
33
20
  components: modules.flatMap((module) => module.migrations?.components ?? []),
34
21
  loader: Effect.all(modules.flatMap((module) => (module.migrations === undefined ? [] : [module.migrations.loader]))).pipe(Effect.map((entries) => entries.flat())),
35
22
  },
36
23
  queues,
37
24
  requestServices: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.requestServices ?? Layer.empty)),
38
- services: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.services)).pipe(Layer.provideMerge(ports)),
25
+ services: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.services ?? Layer.empty)).pipe(Layer.provideMerge(ports)),
39
26
  workers: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.workers ?? Layer.empty)),
40
27
  };
41
28
  });
42
- function moduleName(module) {
43
- return module.module === undefined ? module.name : module.module.declaration.name;
29
+ function servedGroup(module) {
30
+ if (module.module !== undefined) {
31
+ return [module.module];
32
+ }
33
+ return module.group === undefined ? [] : [module.group];
34
+ }
35
+ // The overload types each module's handlers from its operations' services; at run time moduleHandlers reads only its operations.
36
+ function servedHandlers(module) {
37
+ if (module.module !== undefined) {
38
+ return [moduleHandlers({ "~requires": {}, application: module.module.application, declaration: module.module.declaration })];
39
+ }
40
+ return module.handlers === undefined ? [] : [module.handlers];
44
41
  }
45
42
  //# sourceMappingURL=appModules.js.map
@@ -1 +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;AAC7F,OAAO,EAAuC,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAG5G,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA2EhE,MAAM,UAAU,UAAU,CACzB,OAA6B,EAC7B,OAAiD;IAcjD,OAAO,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,OAA6B,EAAE,OAAiD;IACnI,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YACzC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC/B,OAAO,KAAK,CAAC,CAAC,IAAI,oB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C,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Effect } from "effect";
2
+ import type { AppModule } from "#AppModule.ts";
3
+ import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
4
+ export declare const moduleQueues: (modules: readonly AppModule[]) => Effect.Effect<{
5
+ readonly name: string;
6
+ }[], DuplicateModuleQueue, never>;
7
+ //# sourceMappingURL=moduleQueues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moduleQueues.d.ts","sourceRoot":"","sources":["../src/moduleQueues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAYhE,eAAO,MAAM,YAAY;;iCAmBvB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { Effect } from "effect";
2
+ import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
3
+ function queueOwner(module) {
4
+ const name = module.module === undefined ? module.name : module.module.declaration.name;
5
+ return { adminPage: name === undefined ? module.admin?.pages[0]?.id : undefined, name };
6
+ }
7
+ export const moduleQueues = Effect.fnUntraced(function* (modules) {
8
+ const owners = new Map();
9
+ for (const module of modules) {
10
+ for (const queue of module.queues ?? []) {
11
+ const first = owners.get(queue.name);
12
+ const second = queueOwner(module);
13
+ if (first !== undefined) {
14
+ return yield* new DuplicateModuleQueue({
15
+ firstAdminPage: first.adminPage,
16
+ firstModule: first.name,
17
+ queue: queue.name,
18
+ secondAdminPage: second.adminPage,
19
+ secondModule: second.name,
20
+ });
21
+ }
22
+ owners.set(queue.name, second);
23
+ }
24
+ }
25
+ return modules.flatMap((module) => module.queues ?? []);
26
+ });
27
+ //# sourceMappingURL=moduleQueues.js.map
@@ -0,0 +1 @@
1
+ {"version":3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YACJ,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/server",
3
- "version": "0.45.0",
3
+ "version": "0.46.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"
@@ -50,7 +50,7 @@
50
50
  "@shivaedev/contract": "0.58.0",
51
51
  "@shivaedev/errors": "0.14.1",
52
52
  "@shivaedev/http": "0.9.2",
53
- "@shivaedev/identity": "0.42.0",
53
+ "@shivaedev/identity": "0.43.0",
54
54
  "@shivaedev/local-postgres": "0.17.0",
55
55
  "@shivaedev/sql": "0.55.0"
56
56
  },
@@ -59,12 +59,12 @@
59
59
  "@effect/sql-pg": "4.1.4",
60
60
  "@effect/vitest": "4.1.4",
61
61
  "@shivaedev/access": "0.7.0",
62
- "@shivaedev/admin": "0.29.5",
62
+ "@shivaedev/admin": "0.29.6",
63
63
  "@shivaedev/jobs": "0.44.1",
64
64
  "@shivaedev/quality": "0.84.0",
65
65
  "@shivaedev/rate-limit": "0.8.1",
66
66
  "@shivaedev/service": "0.9.2",
67
- "@shivaedev/test-kits": "0.16.9",
67
+ "@shivaedev/test-kits": "0.16.10",
68
68
  "@shivaedev/test-sql": "0.26.1",
69
69
  "@shivaedev/test-story": "0.52.5",
70
70
  "@types/node": "24.19.2",
@@ -78,7 +78,7 @@
78
78
  "@effect/platform-node": "4.1.4",
79
79
  "@effect/sql-pg": "4.1.4",
80
80
  "@effect/vitest": "4.1.4",
81
- "@shivaedev/admin": "0.29.5",
81
+ "@shivaedev/admin": "0.29.6",
82
82
  "better-auth": "1.7.23",
83
83
  "effect": "4.1.4"
84
84
  },
package/src/AppModule.ts CHANGED
@@ -13,12 +13,13 @@ interface ModuleParts {
13
13
  readonly ports?: ModuleLayer;
14
14
  readonly queues?: readonly { readonly name: string }[];
15
15
  readonly requestServices?: Layer.Layer<never, never, unknown>;
16
- readonly services: ModuleLayer;
16
+ readonly services?: ModuleLayer;
17
17
  readonly workers?: ModuleLayer;
18
18
  }
19
19
 
20
- // "~requires" exists only on a defined module, so this branch refuses one and it registers as `module:` instead.
20
+ // "~requires" exists only on a defined module, so the group form refuses one and it registers as `module:` instead.
21
21
  // A defined module already carries its name, so its registration takes none that could disagree with it.
22
+ // A registration that serves no RPCs, such as one with only admin pages, queues or workers, names neither a group nor a module.
22
23
  export type AppModule =
23
24
  | (ModuleParts & {
24
25
  readonly group: RpcGroup.Any & { readonly "~requires"?: never };
@@ -26,7 +27,8 @@ export type AppModule =
26
27
  readonly module?: never;
27
28
  readonly name: string;
28
29
  })
29
- | (ModuleParts & { readonly group?: never; readonly handlers?: never; readonly module: RegisteredModule; readonly name?: never });
30
+ | (ModuleParts & { readonly group?: never; readonly handlers?: never; readonly module: RegisteredModule; readonly name?: never })
31
+ | (ModuleParts & { readonly group?: never; readonly handlers?: never; readonly module?: never; readonly name?: string });
30
32
 
31
33
  // A module's services exist only in its type, and appModules reads them from the registration's own type.
32
34
  export type RegisteredModule = RpcGroup.Any & Pick<AnyModule, "application" | "declaration"> & { readonly "~requires": unknown };
@@ -1,11 +1,26 @@
1
1
  import { Schema } from "effect";
2
2
 
3
+ function owner(name: string | undefined, adminPage: string | undefined) {
4
+ if (name !== undefined) {
5
+ return `"${name}"`;
6
+ }
7
+ return adminPage === undefined ? "a registration with no name" : `the registration of admin page "${adminPage}"`;
8
+ }
9
+
10
+ // A registration without a name is found by its first admin page, and one with neither is only described.
3
11
  export class DuplicateModuleQueue extends Schema.TaggedError<DuplicateModuleQueue>()("DuplicateModuleQueue", {
4
- firstModule: Schema.String,
12
+ firstAdminPage: Schema.optional(Schema.String),
13
+ firstModule: Schema.optional(Schema.String),
5
14
  queue: Schema.String,
6
- secondModule: Schema.String,
15
+ secondAdminPage: Schema.optional(Schema.String),
16
+ secondModule: Schema.optional(Schema.String),
7
17
  }) {
8
18
  override get message() {
9
- return `Queue "${this.queue}" is declared by both "${this.firstModule}" and "${this.secondModule}".`;
19
+ const first = owner(this.firstModule, this.firstAdminPage);
20
+ const second = owner(this.secondModule, this.secondAdminPage);
21
+ const unfound = [first, second].includes("a registration with no name")
22
+ ? " Give the registration with no name a `name` so this message can name it."
23
+ : "";
24
+ return `Queue "${this.queue}" is declared by both ${first} and ${second}.${unfound}`;
10
25
  }
11
26
  }
package/src/appModules.ts CHANGED
@@ -7,8 +7,9 @@ import { mergeAdminRegistrations } from "@shivaedev/admin/server/mergeAdminRegis
7
7
  import { type AnyModule, type ModuleHandlers, moduleHandlers } from "@shivaedev/contract/moduleHandlers.ts";
8
8
  import type { SchemaComponent } from "@shivaedev/sql/SchemaComponent.ts";
9
9
  import type { AppModule, ModuleAdmin, ModuleLayer } from "#AppModule.ts";
10
- import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
10
+ import type { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
11
11
  import type { MigrationOptions } from "#MigrationOptions.ts";
12
+ import { moduleQueues } from "#moduleQueues.ts";
12
13
  import type { ProvidedModules } from "#providedModules.ts";
13
14
  import type { GlobalServices } from "#requestServices.ts";
14
15
 
@@ -102,33 +103,15 @@ export function appModules(
102
103
  }
103
104
 
104
105
  const composeModules = Effect.fnUntraced(function* (modules: readonly AppModule[], options?: { readonly replacements?: ModuleLayer }) {
105
- const owners = new Map<string, string>();
106
- for (const module of modules) {
107
- for (const queue of module.queues ?? []) {
108
- const firstModule = owners.get(queue.name);
109
- if (firstModule !== undefined) {
110
- return yield* new DuplicateModuleQueue({ firstModule, queue: queue.name, secondModule: moduleName(module) });
111
- }
112
- owners.set(queue.name, moduleName(module));
113
- }
114
- }
115
- const queues = modules.flatMap((module) => module.queues ?? []);
106
+ const queues = yield* moduleQueues(modules);
116
107
  const registrations = modules.flatMap((module) => (module.admin === undefined ? [] : [module.admin]));
117
108
  const admin = mergeAdminRegistrations(...registrations);
118
109
  const defaults = Layer.mergeAll(Layer.empty, ...modules.map((module) => module.ports ?? Layer.empty));
119
110
  const ports = Layer.merge(defaults, options?.replacements ?? Layer.empty);
120
111
  return {
121
112
  admin,
122
- group: RpcGroup.make().merge(...modules.map((module) => (module.module === undefined ? module.group : module.module)), admin.group),
123
- // The overload types each module's handlers from its operations' services; at run time moduleHandlers reads only its operations.
124
- handlers: Layer.mergeAll(
125
- admin.handlers,
126
- ...modules.map((module) =>
127
- module.module === undefined
128
- ? module.handlers
129
- : moduleHandlers({ "~requires": {}, application: module.module.application, declaration: module.module.declaration }),
130
- ),
131
- ),
113
+ group: RpcGroup.make().merge(...modules.flatMap(servedGroup), admin.group),
114
+ handlers: Layer.mergeAll(admin.handlers, ...modules.flatMap(servedHandlers)),
132
115
  migrations: {
133
116
  components: modules.flatMap((module) => module.migrations?.components ?? []),
134
117
  loader: Effect.all(modules.flatMap((module) => (module.migrations === undefined ? [] : [module.migrations.loader]))).pipe(
@@ -137,11 +120,22 @@ const composeModules = Effect.fnUntraced(function* (modules: readonly AppModule[
137
120
  },
138
121
  queues,
139
122
  requestServices: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.requestServices ?? Layer.empty)),
140
- services: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.services)).pipe(Layer.provideMerge(ports)),
123
+ services: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.services ?? Layer.empty)).pipe(Layer.provideMerge(ports)),
141
124
  workers: Layer.mergeAll(Layer.empty, ...modules.map((module) => module.workers ?? Layer.empty)),
142
125
  };
143
126
  });
144
127
 
145
- function moduleName(module: AppModule) {
146
- return module.module === undefined ? module.name : module.module.declaration.name;
128
+ function servedGroup(module: AppModule): readonly RpcGroup.Any[] {
129
+ if (module.module !== undefined) {
130
+ return [module.module];
131
+ }
132
+ return module.group === undefined ? [] : [module.group];
133
+ }
134
+
135
+ // The overload types each module's handlers from its operations' services; at run time moduleHandlers reads only its operations.
136
+ function servedHandlers(module: AppModule): readonly ModuleLayer[] {
137
+ if (module.module !== undefined) {
138
+ return [moduleHandlers({ "~requires": {}, application: module.module.application, declaration: module.module.declaration })];
139
+ }
140
+ return module.handlers === undefined ? [] : [module.handlers];
147
141
  }
@@ -0,0 +1,34 @@
1
+ import { Effect } from "effect";
2
+ import type { AppModule } from "#AppModule.ts";
3
+ import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
4
+
5
+ interface QueueOwner {
6
+ readonly adminPage: string | undefined;
7
+ readonly name: string | undefined;
8
+ }
9
+
10
+ function queueOwner(module: AppModule): QueueOwner {
11
+ const name = module.module === undefined ? module.name : module.module.declaration.name;
12
+ return { adminPage: name === undefined ? module.admin?.pages[0]?.id : undefined, name };
13
+ }
14
+
15
+ export const moduleQueues = Effect.fnUntraced(function* (modules: readonly AppModule[]) {
16
+ const owners = new Map<string, QueueOwner>();
17
+ for (const module of modules) {
18
+ for (const queue of module.queues ?? []) {
19
+ const first = owners.get(queue.name);
20
+ const second = queueOwner(module);
21
+ if (first !== undefined) {
22
+ return yield* new DuplicateModuleQueue({
23
+ firstAdminPage: first.adminPage,
24
+ firstModule: first.name,
25
+ queue: queue.name,
26
+ secondAdminPage: second.adminPage,
27
+ secondModule: second.name,
28
+ });
29
+ }
30
+ owners.set(queue.name, second);
31
+ }
32
+ }
33
+ return modules.flatMap((module) => module.queues ?? []);
34
+ });