@shivaedev/server 0.37.0 → 0.38.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 +10 -0
- package/README.md +12 -5
- package/dist/adapters/migrationsIn.d.ts.map +1 -1
- package/dist/adapters/migrationsIn.js +3 -5
- package/dist/adapters/migrationsIn.js.map +1 -1
- package/dist/appModules.d.ts +3 -2
- package/dist/appModules.d.ts.map +1 -1
- package/dist/appModules.js +2 -2
- package/dist/appModules.js.map +1 -1
- package/dist/providedModules.d.ts +24 -0
- package/dist/providedModules.d.ts.map +1 -0
- package/dist/providedModules.js +2 -0
- package/dist/providedModules.js.map +1 -0
- package/package.json +15 -15
- package/src/AppModule.ts +1 -1
- package/src/adapters/migrationsIn.ts +3 -7
- package/src/appModules.ts +7 -5
- package/src/providedModules.ts +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.0 - 2026-11-20
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- `migrationsIn(directory)` finds the `migrations` folder in `directory` through `migrationsFromDirectory` from `@shivaedev/sql/migrationsFromDirectory.ts`, so a module registration and a runner outside the host share one discovery path and one folder convention.
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
|
|
11
|
+
- `appModules` refuses, at compile time, a registration list in which a defined module's operation yields a service that no registration's `services`, `ports` or `requestServices` provide and the host does not provide. The message names the problem as `OperationServicesNotProvided<"<module>", "<operation>", <Service>>` from `@shivaedev/server/providedModules.ts`. A service an application used to provide around the host, or only through `replacements`, moves into a registration's `services` or `ports`.
|
|
12
|
+
|
|
3
13
|
## 0.37.0 - 2026-11-20
|
|
4
14
|
|
|
5
15
|
### Added
|
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/adapters/migrationsIn.ts` returns `{ loader }` for the `migrations` folder in `directory`,
|
|
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/adapters/migrationsIn.ts` returns `{ loader }` for the `migrations` folder in `directory`, found by `migrationsFromDirectory` from `@shivaedev/sql/migrationsFromDirectory.ts` under Node's `NodeServices.layer`, so a registration 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";
|
|
@@ -102,18 +102,18 @@ const hosts = Effect.gen(function* () {
|
|
|
102
102
|
});
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
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
|
|
105
|
+
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:
|
|
106
106
|
|
|
107
107
|
```ts
|
|
108
108
|
import { Layer } from "effect";
|
|
109
|
-
import { SqlClient } from "effect/sql";
|
|
110
109
|
import { defineModule } from "@shivaedev/contract/defineModule.ts";
|
|
111
110
|
import { migrationsIn } from "@shivaedev/server/adapters/migrationsIn.ts";
|
|
112
111
|
import type { AppModule } from "@shivaedev/server/AppModule.ts";
|
|
112
|
+
import { notesWire } from "#generated/modules/notes/Notes.ts";
|
|
113
113
|
import { Create, Get } from "./notes/operations.ts";
|
|
114
114
|
import { Drafts, readDraft } from "./drafts.ts";
|
|
115
115
|
|
|
116
|
-
export const Notes = defineModule({ name: "notes", operations: [Create, Get],
|
|
116
|
+
export const Notes = defineModule({ name: "notes", operations: [Create, Get], wire: notesWire });
|
|
117
117
|
|
|
118
118
|
export const notes = { migrations: migrationsIn(import.meta.dirname), module: Notes, services: Layer.empty } satisfies AppModule;
|
|
119
119
|
|
|
@@ -127,7 +127,14 @@ export const drafts = {
|
|
|
127
127
|
|
|
128
128
|
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.
|
|
129
129
|
|
|
130
|
-
`appModules`
|
|
130
|
+
`appModules` refuses a registration list in which a defined module's operation yields a service that no registration's `services`, `ports` or `requestServices` provide and the host does not provide, as it provides the SQL client and `Reactivity`. The second line of the compiler's message names the module, the operation and each missing service:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
src/test-support/compiler-fixtures/unprovidedService.ts(26,12): error TS2345: Argument of type '[{ module: Module<"imports", readonly [ServedCommand<"importTitle", Struct<{ id: Number; }>, String, Flat<Automatic>, Effect<string, never, NoteSource>>] & readonly ModuleOperation[], ModuleRequirements<...>, never, undefined, undefined>; services: Layer<...>; }]' is not assignable to parameter of type 'readonly [{ module: Module<"imports", readonly [ServedCommand<"importTitle", Struct<{ id: Number; }>, String, Flat<Automatic>, Effect<string, never, NoteSource>>] & readonly ModuleOperation[], ModuleRequirements<...>, never, undefined, undefined>; services: Layer<...>; }] & { ...; } & OperationServicesNotProvided<...>'.
|
|
134
|
+
Type '[{ module: Module<"imports", readonly [ServedCommand<"importTitle", Struct<{ id: Number; }>, String, Flat<Automatic>, Effect<string, never, NoteSource>>] & readonly ModuleOperation[], ModuleRequirements<...>, never, undefined, undefined>; services: Layer<...>; }]' is not assignable to type 'OperationServicesNotProvided<"imports", "importTitle", NoteSource>'.
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
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.
|
|
131
138
|
|
|
132
139
|
`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.
|
|
133
140
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationsIn.d.ts","sourceRoot":"","sources":["../../src/adapters/migrationsIn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"migrationsIn.d.ts","sourceRoot":"","sources":["../../src/adapters/migrationsIn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM;IACpC,MAAM;EACf"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
2
|
-
import { Effect
|
|
3
|
-
import
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { migrationsFromDirectory } from "@shivaedev/sql/migrationsFromDirectory.ts";
|
|
4
4
|
// Node supplies the file system here, so a registration's migrations need nothing from the host that runs them.
|
|
5
5
|
export function migrationsIn(directory) {
|
|
6
|
-
return {
|
|
7
|
-
loader: Effect.flatMap(Path.Path, (path) => MigratorFileSystem.fromFileSystem(path.join(directory, "migrations"))).pipe(Effect.provide(NodeServices.layer)),
|
|
8
|
-
};
|
|
6
|
+
return { loader: migrationsFromDirectory(directory).pipe(Effect.provide(NodeServices.layer)) };
|
|
9
7
|
}
|
|
10
8
|
//# sourceMappingURL=migrationsIn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationsIn.js","sourceRoot":"","sources":["../../src/adapters/migrationsIn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"migrationsIn.js","sourceRoot":"","sources":["../../src/adapters/migrationsIn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAEpF,gHAAgH;AAChH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC7C,OAAO,EAAE,MAAM,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAChG,CAAC"}
|
package/dist/appModules.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { type AnyModule, type ModuleHandlers } from "@shivaedev/contract/moduleH
|
|
|
7
7
|
import type { SchemaComponent } from "@shivaedev/sql/SchemaComponent.ts";
|
|
8
8
|
import type { AppModule, ModuleAdmin } from "#AppModule.ts";
|
|
9
9
|
import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
|
|
10
|
+
import type { ProvidedModules } from "#providedModules.ts";
|
|
10
11
|
import type { GlobalServices } from "#requestServices.ts";
|
|
11
12
|
type ModuleField<TModules, TKey extends PropertyKey> = TModules extends unknown ? (TKey extends keyof TModules ? TModules[TKey] : never) : never;
|
|
12
13
|
type Layers<TModules extends readonly AppModule[], TKey extends "handlers" | "services" | "ports" | "workers" | "requestServices"> = Extract<ModuleField<TModules[number], TKey>, Layer.Any>;
|
|
@@ -18,7 +19,7 @@ type WidenedModule<TModule> = TModule extends {
|
|
|
18
19
|
} ? (TDefined extends AnyModule ? never : TModule) : never;
|
|
19
20
|
type ExactModules<TModules extends readonly AppModule[]> = number extends TModules["length"] ? unknown : {
|
|
20
21
|
readonly [TKey in keyof TModules]: [WidenedModule<TModules[TKey]>] extends [never] ? unknown : {
|
|
21
|
-
readonly "Declare a defined module's registration with satisfies AppModule so its type keeps the module's
|
|
22
|
+
readonly "Declare a defined module's registration with satisfies AppModule so its type keeps the module's services": never;
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
25
|
type Groups<TModules extends readonly AppModule[]> = Extract<ModuleField<TModules[number], "group"> | ModuleField<TModules[number], "module">, RpcGroup.Any>;
|
|
@@ -38,7 +39,7 @@ type Migrations<TModules extends readonly AppModule[]> = ModuleField<TModules[nu
|
|
|
38
39
|
type MigrationRequirements<TModules extends readonly AppModule[]> = Effect.Services<ModuleField<Migrations<TModules>, "loader">>;
|
|
39
40
|
type Components<T> = T extends readonly (infer TComponent extends SchemaComponent<unknown, unknown>)[] ? TComponent : never;
|
|
40
41
|
type ModuleComponents<TModules extends readonly AppModule[]> = Components<ModuleField<Migrations<TModules>, "components">>;
|
|
41
|
-
export declare function appModules<const TModules extends readonly AppModule[], R = never, E = never, TRequirements = never>(modules: TModules & GlobalServices<Layer.Services<Services<NoInfer<TModules>>>, Layer.Success<RequestServices<NoInfer<TModules>>>> & ExactModules<NoInfer<TModules>>, options?: {
|
|
42
|
+
export declare function appModules<const TModules extends readonly AppModule[], R = never, E = never, TRequirements = never>(modules: TModules & GlobalServices<Layer.Services<Services<NoInfer<TModules>>>, Layer.Success<RequestServices<NoInfer<TModules>>>> & ExactModules<NoInfer<TModules>> & ProvidedModules<NoInfer<TModules>>, options?: {
|
|
42
43
|
readonly replacements?: Layer.Layer<R, E, TRequirements>;
|
|
43
44
|
}): Effect.Effect<{
|
|
44
45
|
readonly workers: Layer.Layer<Layer.Success<Layers<TModules, "workers">>, Layer.Error<Layers<TModules, "workers">>, Layer.Services<Layers<TModules, "workers">>>;
|
package/dist/appModules.d.ts.map
CHANGED
|
@@ -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;AACt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,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"}
|
package/dist/appModules.js
CHANGED
|
@@ -25,10 +25,10 @@ const composeModules = Effect.fnUntraced(function* (modules, options) {
|
|
|
25
25
|
return {
|
|
26
26
|
admin,
|
|
27
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
|
|
28
|
+
// The overload types each module's handlers from its operations' services; at run time moduleHandlers reads only its operations.
|
|
29
29
|
handlers: Layer.mergeAll(admin.handlers, ...modules.map((module) => module.module === undefined
|
|
30
30
|
? module.handlers
|
|
31
|
-
: moduleHandlers({ "~requires":
|
|
31
|
+
: moduleHandlers({ "~requires": {}, application: module.module.application, declaration: module.module.declaration }))),
|
|
32
32
|
migrations: {
|
|
33
33
|
components: modules.flatMap((module) => module.migrations?.components ?? []),
|
|
34
34
|
loader: Effect.all(modules.flatMap((module) => (module.migrations === undefined ? [] : [module.migrations.loader]))).pipe(Effect.map((entries) => entries.flat())),
|
package/dist/appModules.js.map
CHANGED
|
@@ -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;
|
|
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,WA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AC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAClH,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;KAC/F,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,MAAiB;IACpC,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Layer } from "effect";
|
|
2
|
+
import type { AnyModule } from "@shivaedev/contract/moduleHandlers.ts";
|
|
3
|
+
import type { AppModule } from "#AppModule.ts";
|
|
4
|
+
import type { hostHttpServices } from "#adapters/hostHttpServices.ts";
|
|
5
|
+
import type { appDatabase } from "#appDatabase.ts";
|
|
6
|
+
export interface OperationServicesNotProvided<TModule extends string, TOperation extends PropertyKey, TMissing> {
|
|
7
|
+
readonly missingServices: TMissing;
|
|
8
|
+
readonly module: TModule;
|
|
9
|
+
readonly operation: TOperation;
|
|
10
|
+
readonly problem: "run or readPolicy uses services that no registration's services, ports or requestServices provide and the host does not provide";
|
|
11
|
+
}
|
|
12
|
+
type HostServices = Layer.Success<ReturnType<typeof appDatabase<never, never>>> | Layer.Success<typeof hostHttpServices>;
|
|
13
|
+
type Field<TModule, TKey extends PropertyKey> = TModule extends unknown ? (TKey extends keyof TModule ? TModule[TKey] : never) : never;
|
|
14
|
+
type Provided<TModules extends readonly AppModule[]> = Layer.Success<Extract<Field<TModules[number], "services" | "ports" | "requestServices">, Layer.Any>> | HostServices;
|
|
15
|
+
type Unprovided<TDefined extends AnyModule, TProvided> = {
|
|
16
|
+
readonly [TOperation in keyof TDefined["~requires"]]: [Exclude<TDefined["~requires"][TOperation], TProvided>] extends [never] ? never : OperationServicesNotProvided<TDefined["declaration"]["name"], TOperation, Exclude<TDefined["~requires"][TOperation], TProvided>>;
|
|
17
|
+
}[keyof TDefined["~requires"]];
|
|
18
|
+
type Shown<TProblem> = TProblem extends OperationServicesNotProvided<infer TName, infer TOperation, infer TMissing> ? OperationServicesNotProvided<TName, TOperation, TMissing> : never;
|
|
19
|
+
type ModuleProblems<TModule, TProvided> = TModule extends {
|
|
20
|
+
readonly module: infer TDefined extends AnyModule;
|
|
21
|
+
} ? Shown<Unprovided<TDefined, TProvided>> : never;
|
|
22
|
+
export type ProvidedModules<TModules extends readonly AppModule[]> = number extends TModules["length"] ? unknown : [ModuleProblems<TModules[number], Provided<TModules>>] extends [never] ? unknown : ModuleProblems<TModules[number], Provided<TModules>>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=providedModules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providedModules.d.ts","sourceRoot":"","sources":["../src/providedModules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,4BAA4B,CAAC,OAAO,SAAS,MAAM,EAAE,UAAU,SAAS,WAAW,EAAE,QAAQ;IAC7G,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;I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,MAAM,UAAU,EAAE,MAAM,QAAQ,CAAC,GACzF,4BAA4B,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,GACzD,KAAK,CAAC;AACV,KAAK,cAAc,CAAC,OAAO,EAAE,SAAS,IAAI,OAAO,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,QAAQ,SAAS,SAAS,CAAA;CAAE,GAC5G,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,GACtC,KAAK,CAAC;AAGT,MAAM,MAAM,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,IAAI,MAAM,SAAS,QAAQ,CAAC,QAAQ,CAAC,GACnG,OAAO,GACP,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACrE,OAAO,GACP,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providedModules.js","sourceRoot":"","sources":["../src/providedModules.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.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"
|
|
@@ -47,26 +47,26 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@shivaedev/changes": "0.14.1",
|
|
50
|
-
"@shivaedev/contract": "0.
|
|
51
|
-
"@shivaedev/errors": "0.
|
|
52
|
-
"@shivaedev/http": "0.9.
|
|
53
|
-
"@shivaedev/identity": "0.34.
|
|
50
|
+
"@shivaedev/contract": "0.50.0",
|
|
51
|
+
"@shivaedev/errors": "0.14.0",
|
|
52
|
+
"@shivaedev/http": "0.9.1",
|
|
53
|
+
"@shivaedev/identity": "0.34.1",
|
|
54
54
|
"@shivaedev/local-postgres": "0.16.2",
|
|
55
|
-
"@shivaedev/sql": "0.
|
|
55
|
+
"@shivaedev/sql": "0.52.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@effect/platform-node": "4.1.4",
|
|
59
59
|
"@effect/sql-pg": "4.1.4",
|
|
60
60
|
"@effect/vitest": "4.1.4",
|
|
61
|
-
"@shivaedev/access": "0.6.
|
|
62
|
-
"@shivaedev/admin": "0.
|
|
63
|
-
"@shivaedev/jobs": "0.43.
|
|
64
|
-
"@shivaedev/quality": "0.78.
|
|
65
|
-
"@shivaedev/rate-limit": "0.6.
|
|
61
|
+
"@shivaedev/access": "0.6.6",
|
|
62
|
+
"@shivaedev/admin": "0.27.0",
|
|
63
|
+
"@shivaedev/jobs": "0.43.1",
|
|
64
|
+
"@shivaedev/quality": "0.78.6",
|
|
65
|
+
"@shivaedev/rate-limit": "0.6.15",
|
|
66
66
|
"@shivaedev/service": "0.9.2",
|
|
67
|
-
"@shivaedev/test-kits": "0.13.
|
|
68
|
-
"@shivaedev/test-sql": "0.25.
|
|
69
|
-
"@shivaedev/test-story": "0.49.
|
|
67
|
+
"@shivaedev/test-kits": "0.13.5",
|
|
68
|
+
"@shivaedev/test-sql": "0.25.5",
|
|
69
|
+
"@shivaedev/test-story": "0.49.1",
|
|
70
70
|
"@types/node": "24.19.2",
|
|
71
71
|
"better-auth": "1.7.22",
|
|
72
72
|
"effect": "4.1.4",
|
|
@@ -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.
|
|
81
|
+
"@shivaedev/admin": "0.27.0",
|
|
82
82
|
"better-auth": "1.7.22",
|
|
83
83
|
"effect": "4.1.4"
|
|
84
84
|
},
|
package/src/AppModule.ts
CHANGED
|
@@ -28,5 +28,5 @@ export type AppModule =
|
|
|
28
28
|
})
|
|
29
29
|
| (ModuleParts & { readonly group?: never; readonly handlers?: never; readonly module: RegisteredModule; readonly name?: never });
|
|
30
30
|
|
|
31
|
-
// A module's
|
|
31
|
+
// A module's services exist only in its type, and appModules reads them from the registration's own type.
|
|
32
32
|
export type RegisteredModule = RpcGroup.Any & Pick<AnyModule, "application" | "declaration"> & { readonly "~requires": unknown };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
2
|
-
import { Effect
|
|
3
|
-
import
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { migrationsFromDirectory } from "@shivaedev/sql/migrationsFromDirectory.ts";
|
|
4
4
|
|
|
5
5
|
// Node supplies the file system here, so a registration's migrations need nothing from the host that runs them.
|
|
6
6
|
export function migrationsIn(directory: string) {
|
|
7
|
-
return {
|
|
8
|
-
loader: Effect.flatMap(Path.Path, (path) => MigratorFileSystem.fromFileSystem(path.join(directory, "migrations"))).pipe(
|
|
9
|
-
Effect.provide(NodeServices.layer),
|
|
10
|
-
),
|
|
11
|
-
};
|
|
7
|
+
return { loader: migrationsFromDirectory(directory).pipe(Effect.provide(NodeServices.layer)) };
|
|
12
8
|
}
|
package/src/appModules.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { SchemaComponent } from "@shivaedev/sql/SchemaComponent.ts";
|
|
|
9
9
|
import type { AppModule, ModuleAdmin, ModuleLayer } from "#AppModule.ts";
|
|
10
10
|
import { DuplicateModuleQueue } from "#DuplicateModuleQueue.ts";
|
|
11
11
|
import type { MigrationOptions } from "#MigrationOptions.ts";
|
|
12
|
+
import type { ProvidedModules } from "#providedModules.ts";
|
|
12
13
|
import type { GlobalServices } from "#requestServices.ts";
|
|
13
14
|
|
|
14
15
|
type ModuleField<TModules, TKey extends PropertyKey> = TModules extends unknown ? (TKey extends keyof TModules ? TModules[TKey] : never) : never;
|
|
@@ -17,7 +18,7 @@ type Layers<TModules extends readonly AppModule[], TKey extends "handlers" | "se
|
|
|
17
18
|
Layer.Any
|
|
18
19
|
>;
|
|
19
20
|
type ServedHandlers<TModule> = TModule extends { readonly module: infer TDefined extends AnyModule } ? ModuleHandlers<TDefined> : never;
|
|
20
|
-
// A registration typed as AppModule has lost its module's
|
|
21
|
+
// A registration typed as AppModule has lost its module's services, so ServedHandlers would serve it as requiring nothing.
|
|
21
22
|
// Only a tuple is checked: inference sees the bare constraint, and a check that refuses it breaks inference of every registration list.
|
|
22
23
|
type WidenedModule<TModule> = TModule extends { readonly module: infer TDefined } ? (TDefined extends AnyModule ? never : TModule) : never;
|
|
23
24
|
type ExactModules<TModules extends readonly AppModule[]> = number extends TModules["length"]
|
|
@@ -25,7 +26,7 @@ type ExactModules<TModules extends readonly AppModule[]> = number extends TModul
|
|
|
25
26
|
: {
|
|
26
27
|
readonly [TKey in keyof TModules]: [WidenedModule<TModules[TKey]>] extends [never]
|
|
27
28
|
? unknown
|
|
28
|
-
: { readonly "Declare a defined module's registration with satisfies AppModule so its type keeps the module's
|
|
29
|
+
: { readonly "Declare a defined module's registration with satisfies AppModule so its type keeps the module's services": never };
|
|
29
30
|
};
|
|
30
31
|
type Groups<TModules extends readonly AppModule[]> = Extract<
|
|
31
32
|
ModuleField<TModules[number], "group"> | ModuleField<TModules[number], "module">,
|
|
@@ -50,7 +51,8 @@ type ModuleComponents<TModules extends readonly AppModule[]> = Components<Module
|
|
|
50
51
|
export function appModules<const TModules extends readonly AppModule[], R = never, E = never, TRequirements = never>(
|
|
51
52
|
modules: TModules &
|
|
52
53
|
GlobalServices<Layer.Services<Services<NoInfer<TModules>>>, Layer.Success<RequestServices<NoInfer<TModules>>>> &
|
|
53
|
-
ExactModules<NoInfer<TModules
|
|
54
|
+
ExactModules<NoInfer<TModules>> &
|
|
55
|
+
ProvidedModules<NoInfer<TModules>>,
|
|
54
56
|
options?: { readonly replacements?: Layer.Layer<R, E, TRequirements> },
|
|
55
57
|
): Effect.Effect<
|
|
56
58
|
{
|
|
@@ -118,13 +120,13 @@ const composeModules = Effect.fnUntraced(function* (modules: readonly AppModule[
|
|
|
118
120
|
return {
|
|
119
121
|
admin,
|
|
120
122
|
group: RpcGroup.make().merge(...modules.map((module) => (module.module === undefined ? module.group : module.module)), admin.group),
|
|
121
|
-
// The overload types each module's handlers from its
|
|
123
|
+
// The overload types each module's handlers from its operations' services; at run time moduleHandlers reads only its operations.
|
|
122
124
|
handlers: Layer.mergeAll(
|
|
123
125
|
admin.handlers,
|
|
124
126
|
...modules.map((module) =>
|
|
125
127
|
module.module === undefined
|
|
126
128
|
? module.handlers
|
|
127
|
-
: moduleHandlers({ "~requires":
|
|
129
|
+
: moduleHandlers({ "~requires": {}, application: module.module.application, declaration: module.module.declaration }),
|
|
128
130
|
),
|
|
129
131
|
),
|
|
130
132
|
migrations: {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Layer } from "effect";
|
|
2
|
+
import type { AnyModule } from "@shivaedev/contract/moduleHandlers.ts";
|
|
3
|
+
import type { AppModule } from "#AppModule.ts";
|
|
4
|
+
import type { hostHttpServices } from "#adapters/hostHttpServices.ts";
|
|
5
|
+
import type { appDatabase } from "#appDatabase.ts";
|
|
6
|
+
|
|
7
|
+
export interface OperationServicesNotProvided<TModule extends string, TOperation extends PropertyKey, TMissing> {
|
|
8
|
+
readonly missingServices: TMissing;
|
|
9
|
+
readonly module: TModule;
|
|
10
|
+
readonly operation: TOperation;
|
|
11
|
+
readonly problem: "run or readPolicy uses services that no registration's services, ports or requestServices provide and the host does not provide";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type HostServices = Layer.Success<ReturnType<typeof appDatabase<never, never>>> | Layer.Success<typeof hostHttpServices>;
|
|
15
|
+
type Field<TModule, TKey extends PropertyKey> = TModule extends unknown ? (TKey extends keyof TModule ? TModule[TKey] : never) : never;
|
|
16
|
+
type Provided<TModules extends readonly AppModule[]> =
|
|
17
|
+
| Layer.Success<Extract<Field<TModules[number], "services" | "ports" | "requestServices">, Layer.Any>>
|
|
18
|
+
| HostServices;
|
|
19
|
+
type Unprovided<TDefined extends AnyModule, TProvided> = {
|
|
20
|
+
readonly [TOperation in keyof TDefined["~requires"]]: [Exclude<TDefined["~requires"][TOperation], TProvided>] extends [never]
|
|
21
|
+
? never
|
|
22
|
+
: OperationServicesNotProvided<TDefined["declaration"]["name"], TOperation, Exclude<TDefined["~requires"][TOperation], TProvided>>;
|
|
23
|
+
}[keyof TDefined["~requires"]];
|
|
24
|
+
// Rebuilding each problem drops the Unprovided alias, so the compiler's message shows the problem itself.
|
|
25
|
+
type Shown<TProblem> =
|
|
26
|
+
TProblem extends OperationServicesNotProvided<infer TName, infer TOperation, infer TMissing>
|
|
27
|
+
? OperationServicesNotProvided<TName, TOperation, TMissing>
|
|
28
|
+
: never;
|
|
29
|
+
type ModuleProblems<TModule, TProvided> = TModule extends { readonly module: infer TDefined extends AnyModule }
|
|
30
|
+
? Shown<Unprovided<TDefined, TProvided>>
|
|
31
|
+
: never;
|
|
32
|
+
|
|
33
|
+
// Replacements stay out: they override ports, and a generic replacements Layer would defer the check until it refused every list.
|
|
34
|
+
export type ProvidedModules<TModules extends readonly AppModule[]> = number extends TModules["length"]
|
|
35
|
+
? unknown
|
|
36
|
+
: [ModuleProblems<TModules[number], Provided<TModules>>] extends [never]
|
|
37
|
+
? unknown
|
|
38
|
+
: ModuleProblems<TModules[number], Provided<TModules>>;
|