@shivaedev/service 0.6.0 → 0.6.1

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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.1 - 2026-11-02
4
+
5
+ ### Fixed
6
+
7
+ - Accept native `Context.Reference` keys in `defineService` requirements without treating their `never` identifier as caller-owned `Scope.Scope`.
8
+
3
9
  ## 0.6.0 - 2026-10-30
4
10
 
5
11
  ### Added
package/README.md CHANGED
@@ -65,6 +65,8 @@ The Layer needs `Prefix`. After a caller resolves `Greetings`, `greet` needs no
65
65
 
66
66
  `initialize` and ordinary methods may require the listed services and `Scope.Scope`. The compiler rejects a definition that reads another service. Scope is supplied by the Layer or method caller, so `Scope.Scope` itself cannot appear in `requires`.
67
67
 
68
+ Native `Context.Reference` keys can appear in `requires`. Their defaults make them requirement-free in Effect, so they add no Layer dependency, including when the reference's value is a scope.
69
+
68
70
  Return functions from the method factory, each producing an Effect. An Effect value placed directly in the method record is rejected. Keep the private state behind those functions; it is absent from the emitted public service declaration.
69
71
 
70
72
  ### 2. Annotate generators when inference needs help
@@ -174,6 +176,8 @@ const preserved = Effect.gen(function* () {
174
176
 
175
177
  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
178
 
179
+ A generic method's remaining requirements follow native Effect rules: execution without them is a compile error. Composing the call into a Layer retains those dependencies until they are provided; an initializer cannot use the call unless its service declares those dependencies.
180
+
177
181
  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
182
 
179
183
  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.
@@ -1,9 +1,9 @@
1
1
  import type { Context, Scope } from "effect";
2
- import type { RequirementRecord } from "./ServiceRequirements.ts";
2
+ import type { RequirementRecord } from "#ServiceRequirements.ts";
3
3
  interface ScopeCannotBeDeclaredAsServiceRequirement {
4
4
  readonly _serviceDefinitionError: "Scope.Scope is caller-owned and cannot be declared as a service requirement";
5
5
  }
6
- type ProveRequirement<TRequirement> = TRequirement extends Context.Service.Any ? Context.Service.Identifier<TRequirement> extends Scope.Scope ? ScopeCannotBeDeclaredAsServiceRequirement : TRequirement : never;
6
+ type ProveRequirement<TRequirement> = TRequirement extends Context.Service.Any ? [Context.Service.Identifier<TRequirement>] extends [never] ? TRequirement : Context.Service.Identifier<TRequirement> extends Scope.Scope ? ScopeCannotBeDeclaredAsServiceRequirement : TRequirement : never;
7
7
  export type RequirementProof<TRequirements extends RequirementRecord> = {
8
8
  readonly [TIndex in keyof TRequirements]: ProveRequirement<TRequirements[TIndex]>;
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RequirementProof.d.ts","sourceRoot":"","sources":["../src/RequirementProof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,UAAU,yCAAyC;IAClD,QAAQ,CAAC,uBAAuB,EAAE,6EAA6E,CAAC;CAChH;AAED,KAAK,gBAAgB,CAAC,YAAY,IAAI,YAAY,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG,GAC3E,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,KAAK,CAAC,KAAK,GAC3D,yCAAyC,GACzC,YAAY,GACb,KAAK,CAAC;AAET,MAAM,MAAM,gBAAgB,CAAC,aAAa,SAAS,iBAAiB,IAAI;IACvE,QAAQ,EAAE,MAAM,IAAI,MAAM,aAAa,GAAG,gBAAgB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;CACjF,CAAC"}
1
+ {"version":3,"file":"RequirementProof.d.ts","sourceRoot":"","sources":["../src/RequirementProof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,UAAU,yCAAyC;IAClD,QAAQ,CAAC,uBAAuB,EAAE,6EAA6E,CAAC;CAChH;AAED,KAAK,gBAAgB,CAAC,YAAY,IAAI,YAAY,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG,GAC3E,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACzD,YAAY,GACZ,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,KAAK,CAAC,KAAK,GAC3D,yCAAyC,GACzC,YAAY,GACd,KAAK,CAAC;AAET,MAAM,MAAM,gBAAgB,CAAC,aAAa,SAAS,iBAAiB,IAAI;IACvE,QAAQ,EAAE,MAAM,IAAI,MAAM,aAAa,GAAG,gBAAgB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;CACjF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/service",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
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.46.0",
48
- "@shivaedev/test": "0.11.0",
49
- "@shivaedev/test-story": "0.25.0",
47
+ "@shivaedev/quality": "0.55.0",
48
+ "@shivaedev/test": "0.12.1",
49
+ "@shivaedev/test-story": "0.33.0",
50
50
  "@types/node": "24.19.2",
51
51
  "effect": "4.0.6",
52
52
  "typescript": "7.0.2",
@@ -1,14 +1,16 @@
1
1
  import type { Context, Scope } from "effect";
2
- import type { RequirementRecord } from "./ServiceRequirements.ts";
2
+ import type { RequirementRecord } from "#ServiceRequirements.ts";
3
3
 
4
4
  interface ScopeCannotBeDeclaredAsServiceRequirement {
5
5
  readonly _serviceDefinitionError: "Scope.Scope is caller-owned and cannot be declared as a service requirement";
6
6
  }
7
7
 
8
8
  type ProveRequirement<TRequirement> = TRequirement extends Context.Service.Any
9
- ? Context.Service.Identifier<TRequirement> extends Scope.Scope
10
- ? ScopeCannotBeDeclaredAsServiceRequirement
11
- : TRequirement
9
+ ? [Context.Service.Identifier<TRequirement>] extends [never]
10
+ ? TRequirement
11
+ : Context.Service.Identifier<TRequirement> extends Scope.Scope
12
+ ? ScopeCannotBeDeclaredAsServiceRequirement
13
+ : TRequirement
12
14
  : never;
13
15
 
14
16
  export type RequirementProof<TRequirements extends RequirementRecord> = {