@shivaedev/service 0.5.1 → 0.6.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 +3 -3
- package/dist/MethodProof.d.ts +1 -4
- package/dist/MethodProof.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/MethodProof.ts +1 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 - 2026-10-30
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Jobs services share one scoped pg-boss client through the Effect environment. Registration, worker and producer Layers use the same connection and pool settings.
|
|
8
|
+
- Service definitions accept marked generic methods alongside declared dependencies. Generic signatures retain their caller requirements unchanged; initialization can capture declared dependencies as private state.
|
|
9
|
+
|
|
10
|
+
### Breaking
|
|
11
|
+
|
|
12
|
+
- Move connection, pool, client factory, cache key and stop options from each `Jobs.layer` call into one `pgBossLayer` from `@shivaedev/jobs/server/service.ts`. Supply `connectionString` as `Redacted<string>` and provide that Layer to the merged jobs services. Keep only `jobs` and `onError` in `Jobs.layer`.
|
|
13
|
+
- Call `jobs.health()` instead of yielding `jobs.health`. Custom jobs service implementations must expose health as a method. Admin's built-in jobs handlers call the method automatically. Jobs services passed to webhook routes and enqueue helpers must also implement the new method shape.
|
|
14
|
+
|
|
3
15
|
## 0.5.1 - 2026-10-30
|
|
4
16
|
|
|
5
17
|
### Changed
|
package/README.md
CHANGED
|
@@ -144,7 +144,7 @@ The replacement provides the public method interface, rather than private initia
|
|
|
144
144
|
|
|
145
145
|
### Preserve a generic method's signature
|
|
146
146
|
|
|
147
|
-
Ordinary methods have one concrete signature.
|
|
147
|
+
Ordinary methods have one concrete signature. `genericMethod` marks a generic function so its success, failure and caller requirements remain related at each call:
|
|
148
148
|
|
|
149
149
|
```ts
|
|
150
150
|
import { Context, Effect } from "effect";
|
|
@@ -174,7 +174,7 @@ const preserved = Effect.gen(function* () {
|
|
|
174
174
|
|
|
175
175
|
The wrapped Effect still requires `Caller`, which the caller supplies separately. The generic service's Layer has no declared dependencies. The emitted declarations preserve the generic success and failure types as well as caller requirements.
|
|
176
176
|
|
|
177
|
-
Marked generic methods
|
|
177
|
+
Marked generic methods also work with declared initializer dependencies. Their signatures keep all caller requirements unchanged; unlike ordinary methods, they do not subtract declared dependencies from the public signature. The compiler rejects an unmarked generic that correlates its input and returned Effect, and a structurally distinct two-signature overload; it may not reject other generic or overloaded signatures. Use initialization state to close over bound dependencies in generic methods.
|
|
178
178
|
|
|
179
179
|
Dependency binding wraps the method's outer returned Effect. A Stream returned as its value retains its own service requirements; provide them when running the Stream.
|
|
180
180
|
|
|
@@ -185,7 +185,7 @@ Import the module that defines the name:
|
|
|
185
185
|
| Module | Name | Use |
|
|
186
186
|
| ------------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
187
187
|
| `@shivaedev/service/defineService.ts` | `defineService(definition)` | Create a native service with its `.layer`. |
|
|
188
|
-
| `@shivaedev/service/genericMethod.ts` | `genericMethod(method)` |
|
|
188
|
+
| `@shivaedev/service/genericMethod.ts` | `genericMethod(method)` | Preserve a generic Effect-returning function and its caller requirements. |
|
|
189
189
|
| `@shivaedev/service/ServiceRequirements.ts` | `ServiceRequirements<Requirements, Success, Failure = never, CallerScope = never>` | Annotate an `Effect.fn` generator with declared dependencies and optional caller scope. |
|
|
190
190
|
|
|
191
191
|
The definition's fields are:
|
package/dist/MethodProof.d.ts
CHANGED
|
@@ -5,9 +5,6 @@ export type MethodEntry = AnyMethod | GenericMethodDescriptor<AnyMethod>;
|
|
|
5
5
|
export type MethodRecord = Readonly<Record<string, AnyMethod>>;
|
|
6
6
|
export type MethodInventory = Readonly<Record<string, unknown>>;
|
|
7
7
|
export type RuntimeMethodInventory = Readonly<Record<string, MethodEntry>>;
|
|
8
|
-
interface GenericMethodWithDeclaredRequirementsIsUnsupported {
|
|
9
|
-
readonly _serviceDefinitionError: "generic methods cannot subtract declared service requirements";
|
|
10
|
-
}
|
|
11
8
|
type MethodRequirements<TMethod> = TMethod extends (...arguments_: readonly never[]) => Effect.Effect<unknown, unknown, infer TRequirements> ? TRequirements : never;
|
|
12
9
|
interface MethodHasUndeclaredServiceRequirements {
|
|
13
10
|
readonly _serviceDefinitionError: "method has service requirements absent from the service declaration";
|
|
@@ -18,7 +15,7 @@ interface ServiceMembersMustBeMethods {
|
|
|
18
15
|
type OrdinaryMethodProof<TMethod, TRequirements extends RequirementRecord> = [
|
|
19
16
|
Exclude<MethodRequirements<TMethod>, RequirementsOf<TRequirements> | Scope.Scope>
|
|
20
17
|
] extends [never] ? TMethod : MethodHasUndeclaredServiceRequirements;
|
|
21
|
-
type SupportedMethod<TMethod, TRequirements extends RequirementRecord> = TMethod extends GenericMethodDescriptor<AnyMethod> ?
|
|
18
|
+
type SupportedMethod<TMethod, TRequirements extends RequirementRecord> = TMethod extends GenericMethodDescriptor<AnyMethod> ? TMethod : TMethod extends AnyMethod ? HasDistinctCallSignatures<TMethod> extends true ? GenericOrStructurallyOverloadedMethodsAreUnsupported : TMethod extends (...arguments_: infer TArguments) => infer TResult ? ((...arguments_: TArguments) => TResult) extends TMethod ? OrdinaryMethodProof<TMethod, TRequirements> : GenericOrStructurallyOverloadedMethodsAreUnsupported : GenericOrStructurallyOverloadedMethodsAreUnsupported : ServiceMembersMustBeMethods;
|
|
22
19
|
export type MethodProof<TMethods extends MethodInventory, TRequirements extends RequirementRecord> = {
|
|
23
20
|
readonly [TName in keyof TMethods]: SupportedMethod<TMethods[TName], TRequirements>;
|
|
24
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MethodProof.d.ts","sourceRoot":"","sources":["../src/MethodProof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACX,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|
"name": "@shivaedev/service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Declared Effect services with scoped initialization and bound dependencies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@effect/vitest": "4.0.6",
|
|
47
|
-
"@shivaedev/quality": "0.
|
|
48
|
-
"@shivaedev/test": "0.
|
|
49
|
-
"@shivaedev/test-story": "0.
|
|
47
|
+
"@shivaedev/quality": "0.46.0",
|
|
48
|
+
"@shivaedev/test": "0.11.0",
|
|
49
|
+
"@shivaedev/test-story": "0.25.0",
|
|
50
50
|
"@types/node": "24.19.2",
|
|
51
51
|
"effect": "4.0.6",
|
|
52
52
|
"typescript": "7.0.2",
|
package/src/MethodProof.ts
CHANGED
|
@@ -15,10 +15,6 @@ export type MethodInventory = Readonly<Record<string, unknown>>;
|
|
|
15
15
|
|
|
16
16
|
export type RuntimeMethodInventory = Readonly<Record<string, MethodEntry>>;
|
|
17
17
|
|
|
18
|
-
interface GenericMethodWithDeclaredRequirementsIsUnsupported {
|
|
19
|
-
readonly _serviceDefinitionError: "generic methods cannot subtract declared service requirements";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
type MethodRequirements<TMethod> = TMethod extends (...arguments_: readonly never[]) => Effect.Effect<unknown, unknown, infer TRequirements>
|
|
23
19
|
? TRequirements
|
|
24
20
|
: never;
|
|
@@ -39,9 +35,7 @@ type OrdinaryMethodProof<TMethod, TRequirements extends RequirementRecord> = [
|
|
|
39
35
|
|
|
40
36
|
type SupportedMethod<TMethod, TRequirements extends RequirementRecord> =
|
|
41
37
|
TMethod extends GenericMethodDescriptor<AnyMethod>
|
|
42
|
-
?
|
|
43
|
-
? TMethod
|
|
44
|
-
: GenericMethodWithDeclaredRequirementsIsUnsupported
|
|
38
|
+
? TMethod
|
|
45
39
|
: TMethod extends AnyMethod
|
|
46
40
|
? HasDistinctCallSignatures<TMethod> extends true
|
|
47
41
|
? GenericOrStructurallyOverloadedMethodsAreUnsupported
|