diff --git a/.changeset/old-pugs-burn.md b/.changeset/old-pugs-burn.md new file mode 100644 index 00000000..fe7094e8 --- /dev/null +++ b/.changeset/old-pugs-burn.md @@ -0,0 +1,5 @@ +--- +"@effect/language-service": patch +--- + +Update the Effect v4 beta examples and type parsing to match the renamed Context APIs in the latest 4.0.0-beta releases. diff --git a/README.md b/README.md index ce5f97d7..81f9531d 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Some diagnostics are off by default or have a default severity of suggestion, bu redundantSchemaTagIdentifier💡🔧Suggests removing redundant identifier argument when it equals the tag value in Schema.TaggedClass/TaggedError/TaggedRequest✓✓ schemaStructWithTag💡🔧Suggests using Schema.TaggedStruct instead of Schema.Struct with _tag field✓✓ schemaUnionOfLiterals➖🔧Simplifies Schema.Union of multiple Schema.Literal calls into single Schema.Literal✓ - serviceNotAsClass➖🔧Warns when ServiceMap.Service is used as a variable instead of a class declaration✓ + serviceNotAsClass➖🔧Warns when Context.Service is used as a variable instead of a class declaration✓ strictBooleanExpressions➖Enforces boolean types in conditional expressions for type safety✓✓ unnecessaryArrowBlock➖🔧Suggests using a concise arrow body when the block only returns an expression✓✓ unnecessaryEffectGen💡🔧Suggests removing Effect.gen when it contains only a single return statement✓✓ diff --git a/packages/harness-effect-v4/__snapshots__/completions.test.ts.snap b/packages/harness-effect-v4/__snapshots__/completions.test.ts.snap index 65ea9112..5fd9b55d 100644 --- a/packages/harness-effect-v4/__snapshots__/completions.test.ts.snap +++ b/packages/harness-effect-v4/__snapshots__/completions.test.ts.snap @@ -335,27 +335,27 @@ exports[`Completion genFunctionStar > genFunctionStar.ts at 4:24 1`] = ` exports[`Completion genFunctionStar > genFunctionStar_imports.ts at 2:16 1`] = `[]`; -exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses.ts at 4:43 1`] = ` +exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses.ts at 4:40 1`] = ` [ { - "insertText": "ServiceMap.Service()("@effect/harness-effect-v4/MyService"){}", + "insertText": "Context.Service()("@effect/harness-effect-v4/MyService"){}", "isSnippet": true, "kind": "const", "name": "Service", "replacementSpan": { - "length": 11, - "start": 153, + "length": 8, + "start": 147, }, "sortText": "11", }, { - "insertText": "ServiceMap.Service()("@effect/harness-effect-v4/MyService", { make: \${0} }){}", + "insertText": "Context.Service()("@effect/harness-effect-v4/MyService", { make: \${0} }){}", "isSnippet": true, "kind": "const", "name": "Service({ make })", "replacementSpan": { - "length": 11, - "start": 153, + "length": 8, + "start": 147, }, "sortText": "11", }, @@ -371,7 +371,7 @@ exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_directImpo "name": "Service", "replacementSpan": { "length": 7, - "start": 149, + "start": 146, }, "sortText": "11", }, @@ -382,61 +382,61 @@ exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_directImpo "name": "Service({ make })", "replacementSpan": { "length": 7, - "start": 149, + "start": 146, }, "sortText": "11", }, ] `; -exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_identifierKey.ts at 5:43 1`] = ` +exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_identifierKey.ts at 5:40 1`] = ` [ { - "insertText": "ServiceMap.Service()("@effect/harness-effect-v4/MyService"){}", + "insertText": "Context.Service()("@effect/harness-effect-v4/MyService"){}", "isSnippet": true, "kind": "const", "name": "Service", "replacementSpan": { - "length": 11, - "start": 249, + "length": 8, + "start": 243, }, "sortText": "11", }, { - "insertText": "ServiceMap.Service()("@effect/harness-effect-v4/MyService", { make: \${0} }){}", + "insertText": "Context.Service()("@effect/harness-effect-v4/MyService", { make: \${0} }){}", "isSnippet": true, "kind": "const", "name": "Service({ make })", "replacementSpan": { - "length": 11, - "start": 249, + "length": 8, + "start": 243, }, "sortText": "11", }, ] `; -exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_middle.ts at 4:31 1`] = ` +exports[`Completion serviceMapSelfInClasses > serviceMapSelfInClasses_middle.ts at 4:28 1`] = ` [ { - "insertText": "ServiceMap.Service()("@effect/harness-effect-v4/Foo"){}", + "insertText": "Context.Service()("@effect/harness-effect-v4/Foo"){}", "isSnippet": true, "kind": "const", "name": "Service", "replacementSpan": { - "length": 12, - "start": 144, + "length": 9, + "start": 141, }, "sortText": "11", }, { - "insertText": "ServiceMap.Service()("@effect/harness-effect-v4/Foo", { make: \${0} }){}", + "insertText": "Context.Service()("@effect/harness-effect-v4/Foo", { make: \${0} }){}", "isSnippet": true, "kind": "const", "name": "Service({ make })", "replacementSpan": { - "length": 12, - "start": 144, + "length": 9, + "start": 141, }, "sortText": "11", }, diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.codefixes index b12c5724..cb1b073e 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.codefixes @@ -1,34 +1,34 @@ -anyUnknownInErrorContext_skipNextLine from 1140 to 1152 -anyUnknownInErrorContext_skipFile from 1140 to 1152 -anyUnknownInErrorContext_skipNextLine from 1086 to 1106 -anyUnknownInErrorContext_skipFile from 1086 to 1106 -anyUnknownInErrorContext_skipNextLine from 1059 to 1071 -anyUnknownInErrorContext_skipFile from 1059 to 1071 -anyUnknownInErrorContext_skipNextLine from 1024 to 1036 -anyUnknownInErrorContext_skipFile from 1024 to 1036 -anyUnknownInErrorContext_skipNextLine from 991 to 1017 -anyUnknownInErrorContext_skipFile from 991 to 1017 -anyUnknownInErrorContext_skipNextLine from 976 to 988 -anyUnknownInErrorContext_skipFile from 976 to 988 -anyUnknownInErrorContext_skipNextLine from 596 to 616 -anyUnknownInErrorContext_skipFile from 596 to 616 -anyUnknownInErrorContext_skipNextLine from 553 to 579 -anyUnknownInErrorContext_skipFile from 553 to 579 -anyUnknownInErrorContext_skipNextLine from 499 to 516 -anyUnknownInErrorContext_skipFile from 499 to 516 -anyUnknownInErrorContext_skipNextLine from 457 to 481 -anyUnknownInErrorContext_skipFile from 457 to 481 -anyUnknownInErrorContext_skipNextLine from 395 to 413 -anyUnknownInErrorContext_skipFile from 395 to 413 -anyUnknownInErrorContext_skipNextLine from 357 to 377 -anyUnknownInErrorContext_skipFile from 357 to 377 -anyUnknownInErrorContext_skipNextLine from 299 to 313 -anyUnknownInErrorContext_skipFile from 299 to 313 -anyUnknownInErrorContext_skipNextLine from 259 to 281 -anyUnknownInErrorContext_skipFile from 259 to 281 -anyUnknownInErrorContext_skipNextLine from 208 to 222 -anyUnknownInErrorContext_skipFile from 208 to 222 -anyUnknownInErrorContext_skipNextLine from 164 to 190 -anyUnknownInErrorContext_skipFile from 164 to 190 +anyUnknownInErrorContext_skipNextLine from 1136 to 1148 +anyUnknownInErrorContext_skipFile from 1136 to 1148 +anyUnknownInErrorContext_skipNextLine from 1082 to 1102 +anyUnknownInErrorContext_skipFile from 1082 to 1102 +anyUnknownInErrorContext_skipNextLine from 1055 to 1067 +anyUnknownInErrorContext_skipFile from 1055 to 1067 +anyUnknownInErrorContext_skipNextLine from 1020 to 1032 +anyUnknownInErrorContext_skipFile from 1020 to 1032 +anyUnknownInErrorContext_skipNextLine from 988 to 1013 +anyUnknownInErrorContext_skipFile from 988 to 1013 +anyUnknownInErrorContext_skipNextLine from 973 to 985 +anyUnknownInErrorContext_skipFile from 973 to 985 +anyUnknownInErrorContext_skipNextLine from 593 to 613 +anyUnknownInErrorContext_skipFile from 593 to 613 +anyUnknownInErrorContext_skipNextLine from 551 to 576 +anyUnknownInErrorContext_skipFile from 551 to 576 +anyUnknownInErrorContext_skipNextLine from 497 to 514 +anyUnknownInErrorContext_skipFile from 497 to 514 +anyUnknownInErrorContext_skipNextLine from 455 to 479 +anyUnknownInErrorContext_skipFile from 455 to 479 +anyUnknownInErrorContext_skipNextLine from 393 to 411 +anyUnknownInErrorContext_skipFile from 393 to 411 +anyUnknownInErrorContext_skipNextLine from 355 to 375 +anyUnknownInErrorContext_skipFile from 355 to 375 +anyUnknownInErrorContext_skipNextLine from 297 to 311 +anyUnknownInErrorContext_skipFile from 297 to 311 +anyUnknownInErrorContext_skipNextLine from 258 to 279 +anyUnknownInErrorContext_skipFile from 258 to 279 +anyUnknownInErrorContext_skipNextLine from 207 to 221 +anyUnknownInErrorContext_skipFile from 207 to 221 +anyUnknownInErrorContext_skipNextLine from 164 to 189 +anyUnknownInErrorContext_skipFile from 164 to 189 anyUnknownInErrorContext_skipNextLine from 109 to 127 anyUnknownInErrorContext_skipFile from 109 to 127 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.output index 49ec8865..1ee99173 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext.ts.output @@ -2,16 +2,16 @@ withUnknownContext 4:13 - 4:31 | 0 | This has unknown in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) -Effect.services() -5:9 - 5:35 | 0 | This has unknown in the requirements channel which is not recommended. +Effect.context() +5:9 - 5:34 | 0 | This has unknown in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) withAnyContext 8:13 - 8:27 | 0 | This has any in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) -Effect.services() -9:9 - 9:31 | 0 | This has any in the requirements channel which is not recommended. +Effect.context() +9:9 - 9:30 | 0 | This has any in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) withAnyFailure @@ -35,8 +35,8 @@ hasBothAnyUnknown Only service identifiers should appear in the requirements channel. Having an unknown or any error type is not useful. Consider instead using specific error types baked by Data.TaggedError for example. effect(anyUnknownInErrorContext) -Effect.services() -21:9 - 21:35 | 0 | This has unknown in the requirements channel which is not recommended. +Effect.context() +21:9 - 21:34 | 0 | This has unknown in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) Effect.fail(42) @@ -47,8 +47,8 @@ effectUnkown 37:6 - 37:18 | 0 | This has unknown in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) -Effect.services() -37:21 - 37:47 | 0 | This has unknown in the requirements channel which is not recommended. +Effect.context() +37:21 - 37:46 | 0 | This has unknown in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) layerUnknown diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.codefixes index decd843c..f10d7251 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.codefixes @@ -1,6 +1,6 @@ -anyUnknownInErrorContext_skipNextLine from 218 to 242 -anyUnknownInErrorContext_skipFile from 218 to 242 -anyUnknownInErrorContext_skipNextLine from 175 to 201 -anyUnknownInErrorContext_skipFile from 175 to 201 +anyUnknownInErrorContext_skipNextLine from 217 to 241 +anyUnknownInErrorContext_skipFile from 217 to 241 +anyUnknownInErrorContext_skipNextLine from 175 to 200 +anyUnknownInErrorContext_skipFile from 175 to 200 anyUnknownInErrorContext_skipNextLine from 131 to 138 anyUnknownInErrorContext_skipFile from 131 to 138 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.output index 92cc74b1..17d9a405 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/anyUnknownInErrorContext_preview.ts.output @@ -3,8 +3,8 @@ preview Only service identifiers should appear in the requirements channel. Having an unknown or any error type is not useful. Consider instead using specific error types baked by Data.TaggedError for example. effect(anyUnknownInErrorContext) -Effect.services() -6:9 - 6:35 | 0 | This has unknown in the requirements channel which is not recommended. +Effect.context() +6:9 - 6:34 | 0 | This has unknown in the requirements channel which is not recommended. Only service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext) Effect.fail("boom") diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.classSelfMismatch_fix.from308to319.output b/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.classSelfMismatch_fix.from308to319.output new file mode 100644 index 00000000..2cac58fe --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.classSelfMismatch_fix.from308to319.output @@ -0,0 +1,12 @@ +// code fix classSelfMismatch_fix output for range 308 - 319 +import { Context, Effect } from "effect" + +export class CorrectName extends Context.Service Effect.Effect + readCache: Effect.Effect +}>()("CorrectName") {} + +export class WrongName extends Context.Service Effect.Effect + readCache: Effect.Effect +}>()("WrongName") {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.codefixes index 5703d556..617344d9 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.codefixes @@ -1,3 +1,3 @@ -classSelfMismatch_fix from 317 to 328 -classSelfMismatch_skipNextLine from 317 to 328 -classSelfMismatch_skipFile from 317 to 328 \ No newline at end of file +classSelfMismatch_fix from 308 to 319 +classSelfMismatch_skipNextLine from 308 to 319 +classSelfMismatch_skipFile from 308 to 319 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.output index b9870d6c..401c7586 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/classSelfMismatch_service.ts.output @@ -1,2 +1,2 @@ CorrectName -8:50 - 8:61 | 1 | The `Self` type parameter for this class should be `WrongName`. effect(classSelfMismatch) \ No newline at end of file +8:47 - 8:58 | 1 | The `Self` type parameter for this class should be `WrongName`. effect(classSelfMismatch) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.codefixes index a2953ab9..e88ff024 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.codefixes @@ -1,6 +1,6 @@ -deterministicKeys_fix from 321 to 348 -deterministicKeys_skipNextLine from 321 to 348 -deterministicKeys_skipFile from 321 to 348 -deterministicKeys_fix from 399 to 407 -deterministicKeys_skipNextLine from 399 to 407 -deterministicKeys_skipFile from 399 to 407 \ No newline at end of file +deterministicKeys_fix from 315 to 342 +deterministicKeys_skipNextLine from 315 to 342 +deterministicKeys_skipFile from 315 to 342 +deterministicKeys_fix from 393 to 401 +deterministicKeys_skipNextLine from 393 to 401 +deterministicKeys_skipFile from 393 to 401 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.deterministicKeys_fix.from315to342.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.deterministicKeys_fix.from315to342.output new file mode 100644 index 00000000..06fce4e1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.deterministicKeys_fix.from315to342.output @@ -0,0 +1,10 @@ +// code fix deterministicKeys_fix output for range 315 - 342 +// @effect-diagnostics deterministicKeys:error +// @test-config { "keyPatterns": [ { "target": "service", "pattern": "default" }, { "target": "error", "pattern": "default" } ] } +import { Context, Data } from "effect" + +export class ExpectedServiceIdentifier + extends Context.Service()("@effect/harness-effect-v4/ExpectedServiceIdentifier") +{} + +export class ErrorA extends Data.TaggedError("ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.deterministicKeys_fix.from393to401.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.deterministicKeys_fix.from393to401.output new file mode 100644 index 00000000..52b8f9aa --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.deterministicKeys_fix.from393to401.output @@ -0,0 +1,10 @@ +// code fix deterministicKeys_fix output for range 393 - 401 +// @effect-diagnostics deterministicKeys:error +// @test-config { "keyPatterns": [ { "target": "service", "pattern": "default" }, { "target": "error", "pattern": "default" } ] } +import { Context, Data } from "effect" + +export class ExpectedServiceIdentifier + extends Context.Service()("ExpectedServiceIdentifier") +{} + +export class ErrorA extends Data.TaggedError("@effect/harness-effect-v4/ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.output index 4cb0ebc1..8a6f1ec8 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys.ts.output @@ -1,5 +1,5 @@ "ExpectedServiceIdentifier" -6:62 - 6:89 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ExpectedServiceIdentifier`. effect(deterministicKeys) +6:59 - 6:86 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ExpectedServiceIdentifier`. effect(deterministicKeys) "ErrorA" 9:45 - 9:53 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ErrorA`. effect(deterministicKeys) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.codefixes index ca47e2f5..7ef4af77 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.codefixes @@ -1,6 +1,6 @@ -deterministicKeys_fix from 427 to 434 -deterministicKeys_skipNextLine from 427 to 434 -deterministicKeys_skipFile from 427 to 434 -deterministicKeys_fix from 554 to 566 -deterministicKeys_skipNextLine from 554 to 566 -deterministicKeys_skipFile from 554 to 566 \ No newline at end of file +deterministicKeys_fix from 421 to 428 +deterministicKeys_skipNextLine from 421 to 428 +deterministicKeys_skipFile from 421 to 428 +deterministicKeys_fix from 548 to 560 +deterministicKeys_skipNextLine from 548 to 560 +deterministicKeys_skipFile from 548 to 560 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.deterministicKeys_fix.from421to428.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.deterministicKeys_fix.from421to428.output new file mode 100644 index 00000000..d0260d56 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.deterministicKeys_fix.from421to428.output @@ -0,0 +1,20 @@ +// code fix deterministicKeys_fix output for range 421 - 428 +// @effect-diagnostics deterministicKeys:error +// @test-config { "extendedKeyDetection": true } +import * as Persistable from "@/diagnostics/utils" +import { Context } from "effect" + +// simple case inside same file +export function MyConstructor(/** @effect-identifier */ identifier: string) { + return class extends Context.Service()("hey/" + identifier) {} +} + +export class MyClass extends MyConstructor("@effect/harness-effect-v4/MyClass") { +} + +// referenced on another file +export class TTLRequest extends Persistable.Class<{ + payload: { id: number } +}>()("TTLRequest", { + primaryKey: (req) => `TTLRequest:${req.id}` +}) {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.deterministicKeys_fix.from548to560.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.deterministicKeys_fix.from548to560.output new file mode 100644 index 00000000..e4a6ce8b --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_custom.ts.deterministicKeys_fix.from548to560.output @@ -0,0 +1,20 @@ +// code fix deterministicKeys_fix output for range 548 - 560 +// @effect-diagnostics deterministicKeys:error +// @test-config { "extendedKeyDetection": true } +import * as Persistable from "@/diagnostics/utils" +import { Context } from "effect" + +// simple case inside same file +export function MyConstructor(/** @effect-identifier */ identifier: string) { + return class extends Context.Service()("hey/" + identifier) {} +} + +export class MyClass extends MyConstructor("Hello") { +} + +// referenced on another file +export class TTLRequest extends Persistable.Class<{ + payload: { id: number } +}>()("@effect/harness-effect-v4/TTLRequest", { + primaryKey: (req) => `TTLRequest:${req.id}` +}) {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.codefixes index 0e3fef1a..74bfb8ff 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.codefixes @@ -1,6 +1,6 @@ -deterministicKeys_fix from 335 to 362 -deterministicKeys_skipNextLine from 335 to 362 -deterministicKeys_skipFile from 335 to 362 -deterministicKeys_fix from 413 to 421 -deterministicKeys_skipNextLine from 413 to 421 -deterministicKeys_skipFile from 413 to 421 \ No newline at end of file +deterministicKeys_fix from 329 to 356 +deterministicKeys_skipNextLine from 329 to 356 +deterministicKeys_skipFile from 329 to 356 +deterministicKeys_fix from 407 to 415 +deterministicKeys_skipNextLine from 407 to 415 +deterministicKeys_skipFile from 407 to 415 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.deterministicKeys_fix.from329to356.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.deterministicKeys_fix.from329to356.output new file mode 100644 index 00000000..2fd7e9ab --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.deterministicKeys_fix.from329to356.output @@ -0,0 +1,10 @@ +// code fix deterministicKeys_fix output for range 329 - 356 +// @effect-diagnostics deterministicKeys:error +// @test-config { "keyPatterns": [ { "target": "service", "pattern": "default-hashed" }, { "target": "error", "pattern": "default-hashed" } ] } +import { Context, Data } from "effect" + +export class ExpectedServiceIdentifier + extends Context.Service()("fc438e0396fbb4f7") +{} + +export class ErrorA extends Data.TaggedError("ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.deterministicKeys_fix.from407to415.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.deterministicKeys_fix.from407to415.output new file mode 100644 index 00000000..f6e56b6e --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.deterministicKeys_fix.from407to415.output @@ -0,0 +1,10 @@ +// code fix deterministicKeys_fix output for range 407 - 415 +// @effect-diagnostics deterministicKeys:error +// @test-config { "keyPatterns": [ { "target": "service", "pattern": "default-hashed" }, { "target": "error", "pattern": "default-hashed" } ] } +import { Context, Data } from "effect" + +export class ExpectedServiceIdentifier + extends Context.Service()("ExpectedServiceIdentifier") +{} + +export class ErrorA extends Data.TaggedError("0e8acd2c08314dfd")<{}> {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.output index d5e67e5c..45473895 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_defaultHashed.ts.output @@ -1,5 +1,5 @@ "ExpectedServiceIdentifier" -6:62 - 6:89 | 1 | This key does not match the deterministic key for this declaration. The expected key is `fc438e0396fbb4f7`. effect(deterministicKeys) +6:59 - 6:86 | 1 | This key does not match the deterministic key for this declaration. The expected key is `fc438e0396fbb4f7`. effect(deterministicKeys) "ErrorA" 9:45 - 9:53 | 1 | This key does not match the deterministic key for this declaration. The expected key is `0e8acd2c08314dfd`. effect(deterministicKeys) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.codefixes index ef5c7664..f017d137 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.codefixes @@ -1,6 +1,6 @@ -deterministicKeys_fix from 343 to 370 -deterministicKeys_skipNextLine from 343 to 370 -deterministicKeys_skipFile from 343 to 370 -deterministicKeys_fix from 421 to 429 -deterministicKeys_skipNextLine from 421 to 429 -deterministicKeys_skipFile from 421 to 429 \ No newline at end of file +deterministicKeys_fix from 337 to 364 +deterministicKeys_skipNextLine from 337 to 364 +deterministicKeys_skipFile from 337 to 364 +deterministicKeys_fix from 415 to 423 +deterministicKeys_skipNextLine from 415 to 423 +deterministicKeys_skipFile from 415 to 423 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.deterministicKeys_fix.from337to364.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.deterministicKeys_fix.from337to364.output new file mode 100644 index 00000000..1db4d1b3 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.deterministicKeys_fix.from337to364.output @@ -0,0 +1,10 @@ +// code fix deterministicKeys_fix output for range 337 - 364 +// @effect-diagnostics deterministicKeys:error +// @test-config { "keyPatterns": [ { "target": "service", "pattern": "package-identifier" }, { "target": "error", "pattern": "package-identifier" } ] } +import { Context, Data } from "effect" + +export class ExpectedServiceIdentifier + extends Context.Service()("@effect/harness-effect-v4/ExpectedServiceIdentifier") +{} + +export class ErrorA extends Data.TaggedError("ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.deterministicKeys_fix.from415to423.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.deterministicKeys_fix.from415to423.output new file mode 100644 index 00000000..0c6c5a35 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.deterministicKeys_fix.from415to423.output @@ -0,0 +1,10 @@ +// code fix deterministicKeys_fix output for range 415 - 423 +// @effect-diagnostics deterministicKeys:error +// @test-config { "keyPatterns": [ { "target": "service", "pattern": "package-identifier" }, { "target": "error", "pattern": "package-identifier" } ] } +import { Context, Data } from "effect" + +export class ExpectedServiceIdentifier + extends Context.Service()("ExpectedServiceIdentifier") +{} + +export class ErrorA extends Data.TaggedError("@effect/harness-effect-v4/ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.output index 4cb0ebc1..8a6f1ec8 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_packageIdentifier.ts.output @@ -1,5 +1,5 @@ "ExpectedServiceIdentifier" -6:62 - 6:89 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ExpectedServiceIdentifier`. effect(deterministicKeys) +6:59 - 6:86 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ExpectedServiceIdentifier`. effect(deterministicKeys) "ErrorA" 9:45 - 9:53 | 1 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/ErrorA`. effect(deterministicKeys) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.codefixes index 54295189..13489c99 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.codefixes @@ -1,3 +1,3 @@ -deterministicKeys_fix from 277 to 295 -deterministicKeys_skipNextLine from 277 to 295 -deterministicKeys_skipFile from 277 to 295 \ No newline at end of file +deterministicKeys_fix from 271 to 289 +deterministicKeys_skipNextLine from 271 to 289 +deterministicKeys_skipFile from 271 to 289 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.deterministicKeys_fix.from271to289.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.deterministicKeys_fix.from271to289.output new file mode 100644 index 00000000..ce908b7a --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.deterministicKeys_fix.from271to289.output @@ -0,0 +1,8 @@ +// code fix deterministicKeys_fix output for range 271 - 289 +// @effect-diagnostics *:off +// @effect-diagnostics deterministicKeys:warning +// @test-config { "keyPatterns": [{ "target": "service", "pattern": "default" }] } +import { Context } from "effect" + +export class RenamedService + extends Context.Service()("@effect/harness-effect-v4/RenamedService") {} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.output index 45dcc671..bff54023 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/deterministicKeys_preview.ts.output @@ -1,2 +1,2 @@ "CustomIdentifier" -7:51 - 7:69 | 0 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/RenamedService`. effect(deterministicKeys) \ No newline at end of file +7:48 - 7:66 | 0 | This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/RenamedService`. effect(deterministicKeys) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes index ea09c356..adecd592 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.codefixes @@ -1,12 +1,12 @@ -effectFnOpportunity_toEffectFnSpanInferred from 766 to 769 -effectFnOpportunity_skipNextLine from 766 to 769 -effectFnOpportunity_skipFile from 766 to 769 -effectFnOpportunity_toEffectFnSpanInferred from 930 to 933 -effectFnOpportunity_skipNextLine from 930 to 933 -effectFnOpportunity_skipFile from 930 to 933 -effectFnOpportunity_toEffectFnSpanInferred from 388 to 391 -effectFnOpportunity_skipNextLine from 388 to 391 -effectFnOpportunity_skipFile from 388 to 391 -effectFnOpportunity_toEffectFnSpanInferred from 608 to 611 -effectFnOpportunity_skipNextLine from 608 to 611 -effectFnOpportunity_skipFile from 608 to 611 \ No newline at end of file +effectFnOpportunity_toEffectFnSpanInferred from 760 to 763 +effectFnOpportunity_skipNextLine from 760 to 763 +effectFnOpportunity_skipFile from 760 to 763 +effectFnOpportunity_toEffectFnSpanInferred from 924 to 927 +effectFnOpportunity_skipNextLine from 924 to 927 +effectFnOpportunity_skipFile from 924 to 927 +effectFnOpportunity_toEffectFnSpanInferred from 382 to 385 +effectFnOpportunity_skipNextLine from 382 to 385 +effectFnOpportunity_skipFile from 382 to 385 +effectFnOpportunity_toEffectFnSpanInferred from 602 to 605 +effectFnOpportunity_skipNextLine from 602 to 605 +effectFnOpportunity_skipFile from 602 to 605 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from382to385.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from382to385.output new file mode 100644 index 00000000..215d1f15 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from382to385.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 382 - 385 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +class MyService extends Context.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from602to605.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from602to605.output new file mode 100644 index 00000000..7373c508 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from602to605.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 602 - 605 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +class MyService extends Context.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from760to763.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from760to763.output new file mode 100644 index 00000000..5ed90744 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from760to763.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 760 - 763 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +class MyService extends Context.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from924to927.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from924to927.output new file mode 100644 index 00000000..9cd175ba --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayer.ts.effectFnOpportunity_toEffectFnSpanInferred.from924to927.output @@ -0,0 +1,31 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 924 - 927 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +class MyService extends Context.Service Effect.Effect +}>()("MyService") {} + +const _shouldTrigger = Layer.effect(MyService)(Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerConstructor = Layer.effect(MyService, Effect.gen(function*() { + yield* Effect.log("log") + // Log should be inferred with name MyService.log + return { log: (what: string) => Effect.log(what) } +})) + +const _shouldTriggerSucceed = Layer.succeed(MyService)({ + // Log should be inferred with name MyService.log + log: (what: string) => Effect.log(what) +}) + +const _shouldTriggerSync = Layer.sync(MyService)(() => { + // Log should be inferred with name MyService.log + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.codefixes index 17a11603..d794cb8d 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.codefixes @@ -1,9 +1,9 @@ -effectFnOpportunity_toEffectFnSpanInferred from 451 to 454 -effectFnOpportunity_skipNextLine from 451 to 454 -effectFnOpportunity_skipFile from 451 to 454 -effectFnOpportunity_toEffectFnSpanInferred from 564 to 567 -effectFnOpportunity_skipNextLine from 564 to 567 -effectFnOpportunity_skipFile from 564 to 567 -effectFnOpportunity_toEffectFnSpanInferred from 344 to 347 -effectFnOpportunity_skipNextLine from 344 to 347 -effectFnOpportunity_skipFile from 344 to 347 \ No newline at end of file +effectFnOpportunity_toEffectFnSpanInferred from 445 to 448 +effectFnOpportunity_skipNextLine from 445 to 448 +effectFnOpportunity_skipFile from 445 to 448 +effectFnOpportunity_toEffectFnSpanInferred from 558 to 561 +effectFnOpportunity_skipNextLine from 558 to 561 +effectFnOpportunity_skipFile from 558 to 561 +effectFnOpportunity_toEffectFnSpanInferred from 338 to 341 +effectFnOpportunity_skipNextLine from 338 to 341 +effectFnOpportunity_skipFile from 338 to 341 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from338to341.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from338to341.output new file mode 100644 index 00000000..53eda9d1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from338to341.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 338 - 341 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +export class MyService extends Context.Service Effect.Effect +}>()("MyService") { + static layer = Layer.effect(this, Effect.gen(function*() { + yield* Effect.log("log") + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } + })) + + static layerSucceed = Layer.succeed(this)({ + log: (what: string) => Effect.log(what) + }) + + static layerSync = Layer.sync(this)(() => { + return { log: (what: string) => Effect.log(what) } + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from445to448.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from445to448.output new file mode 100644 index 00000000..2f452db1 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from445to448.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 445 - 448 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +export class MyService extends Context.Service Effect.Effect +}>()("MyService") { + static layer = Layer.effect(this, Effect.gen(function*() { + yield* Effect.log("log") + return { log: (what: string) => Effect.log(what) } + })) + + static layerSucceed = Layer.succeed(this)({ + log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) + }) + + static layerSync = Layer.sync(this)(() => { + return { log: (what: string) => Effect.log(what) } + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from558to561.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from558to561.output new file mode 100644 index 00000000..01a6bb32 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredLayerThis.ts.effectFnOpportunity_toEffectFnSpanInferred.from558to561.output @@ -0,0 +1,22 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 558 - 561 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +export class MyService extends Context.Service Effect.Effect +}>()("MyService") { + static layer = Layer.effect(this, Effect.gen(function*() { + yield* Effect.log("log") + return { log: (what: string) => Effect.log(what) } + })) + + static layerSucceed = Layer.succeed(this)({ + log: (what: string) => Effect.log(what) + }) + + static layerSync = Layer.sync(this)(() => { + return { log: Effect.fn("MyService.log")(function(what: string) { + return Effect.log(what) + }) } + }) +} diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredOf.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredOf.ts.codefixes index 55778444..8805fcbf 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredOf.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredOf.ts.codefixes @@ -1,3 +1,3 @@ -effectFnOpportunity_toEffectFnSpanInferred from 310 to 317 -effectFnOpportunity_skipNextLine from 310 to 317 -effectFnOpportunity_skipFile from 310 to 317 \ No newline at end of file +effectFnOpportunity_toEffectFnSpanInferred from 304 to 311 +effectFnOpportunity_skipNextLine from 304 to 311 +effectFnOpportunity_skipFile from 304 to 311 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredOf.ts.effectFnOpportunity_toEffectFnSpanInferred.from304to311.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredOf.ts.effectFnOpportunity_toEffectFnSpanInferred.from304to311.output new file mode 100644 index 00000000..9aaa314b --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredOf.ts.effectFnOpportunity_toEffectFnSpanInferred.from304to311.output @@ -0,0 +1,14 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 304 - 311 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +class UserService extends Context.Service + }>()("UserService") {} + + +const _shouldTrigger = UserService.of({ // UserService is an Effect Tag + getUser: Effect.fn("UserService.getUser")(function*(id: string) { + yield* Effect.log(`Looking up user ${id}`) + }) +}) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredServiceMake.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredServiceMake.ts.codefixes index cb47bf9a..825fab47 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredServiceMake.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredServiceMake.ts.codefixes @@ -1,3 +1,3 @@ -effectFnOpportunity_toEffectFnSpanInferred from 250 to 257 -effectFnOpportunity_skipNextLine from 250 to 257 -effectFnOpportunity_skipFile from 250 to 257 \ No newline at end of file +effectFnOpportunity_toEffectFnSpanInferred from 244 to 251 +effectFnOpportunity_skipNextLine from 244 to 251 +effectFnOpportunity_skipFile from 244 to 251 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredServiceMake.ts.effectFnOpportunity_toEffectFnSpanInferred.from244to251.output b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredServiceMake.ts.effectFnOpportunity_toEffectFnSpanInferred.from244to251.output new file mode 100644 index 00000000..06283b7c --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/effectFnOpportunity_inferredServiceMake.ts.effectFnOpportunity_toEffectFnSpanInferred.from244to251.output @@ -0,0 +1,14 @@ +// code fix effectFnOpportunity_toEffectFnSpanInferred output for range 244 - 251 +// @test-config { "effectFn": ["inferred-span"] } +import { Effect, Layer, Context } from "effect" + +export class UserService extends Context.Service()("UserService", { + make: Effect.gen(function*() { + return { + getUser: Effect.fn("UserService.getUser")(function*(id: string) { + yield* Effect.log(`Looking up user ${id}`) + }) + } + }) +}) {} + diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.codefixes index d394cff5..69c4bdad 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.codefixes @@ -1,12 +1,12 @@ -layerMergeAllWithDependencies_fix from 1103 to 1121 -layerMergeAllWithDependencies_skipNextLine from 1103 to 1121 -layerMergeAllWithDependencies_skipFile from 1103 to 1121 -layerMergeAllWithDependencies_fix from 1246 to 1264 -layerMergeAllWithDependencies_skipNextLine from 1246 to 1264 -layerMergeAllWithDependencies_skipFile from 1246 to 1264 -layerMergeAllWithDependencies_fix from 1222 to 1242 -layerMergeAllWithDependencies_skipNextLine from 1222 to 1242 -layerMergeAllWithDependencies_skipFile from 1222 to 1242 -layerMergeAllWithDependencies_fix from 1268 to 1281 -layerMergeAllWithDependencies_skipNextLine from 1268 to 1281 -layerMergeAllWithDependencies_skipFile from 1268 to 1281 \ No newline at end of file +layerMergeAllWithDependencies_fix from 1088 to 1106 +layerMergeAllWithDependencies_skipNextLine from 1088 to 1106 +layerMergeAllWithDependencies_skipFile from 1088 to 1106 +layerMergeAllWithDependencies_fix from 1231 to 1249 +layerMergeAllWithDependencies_skipNextLine from 1231 to 1249 +layerMergeAllWithDependencies_skipFile from 1231 to 1249 +layerMergeAllWithDependencies_fix from 1207 to 1227 +layerMergeAllWithDependencies_skipNextLine from 1207 to 1227 +layerMergeAllWithDependencies_skipFile from 1207 to 1227 +layerMergeAllWithDependencies_fix from 1253 to 1266 +layerMergeAllWithDependencies_skipNextLine from 1253 to 1266 +layerMergeAllWithDependencies_skipFile from 1253 to 1266 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1088to1106.output b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1088to1106.output new file mode 100644 index 00000000..c41d01f3 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1088to1106.output @@ -0,0 +1,47 @@ +// code fix layerMergeAllWithDependencies_fix output for range 1088 - 1106 +import { Effect, Layer, Context } from "effect" + +export class DbConnection extends Context.Service()("DbConnection", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class FileSystem extends Context.Service()("FileSystem", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class Cache extends Context.Service()("Cache", { + make: Effect.as(FileSystem.asEffect(), {}) +}) { + static Default = Layer.effect(this, this.make) +} +export class UserRepository extends Context.Service()("UserRepository", { + make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) +}) { + static Default = Layer.effect(this, this.make) +} + +const cachePassthrough = Layer.effect(Cache, Cache.asEffect()) + +export const shouldNotWarn = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default +) + +export const shouldNotWarn2 = Layer.mergeAll( + UserRepository.Default, + cachePassthrough +) + +export const shouldWarn = Layer.mergeAll( + DbConnection.Default, + Cache.Default // <- this requires a DbConnection +).pipe(Layer.provideMerge(FileSystem.Default)) + +export const shouldWarn2 = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default, + Cache.Default, // <- this requires a FileSystem, + UserRepository.Default // <- this requires a DbConnection +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1207to1227.output b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1207to1227.output new file mode 100644 index 00000000..7de4b72b --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1207to1227.output @@ -0,0 +1,47 @@ +// code fix layerMergeAllWithDependencies_fix output for range 1207 - 1227 +import { Effect, Layer, Context } from "effect" + +export class DbConnection extends Context.Service()("DbConnection", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class FileSystem extends Context.Service()("FileSystem", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class Cache extends Context.Service()("Cache", { + make: Effect.as(FileSystem.asEffect(), {}) +}) { + static Default = Layer.effect(this, this.make) +} +export class UserRepository extends Context.Service()("UserRepository", { + make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) +}) { + static Default = Layer.effect(this, this.make) +} + +const cachePassthrough = Layer.effect(Cache, Cache.asEffect()) + +export const shouldNotWarn = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default +) + +export const shouldNotWarn2 = Layer.mergeAll( + UserRepository.Default, + cachePassthrough +) + +export const shouldWarn = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default, + Cache.Default // <- this requires a DbConnection +) + +export const shouldWarn2 = Layer.mergeAll( + FileSystem.Default, + Cache.Default, // <- this requires a FileSystem, + UserRepository.Default // <- this requires a DbConnection +).pipe(Layer.provideMerge(DbConnection.Default)) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1231to1249.output b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1231to1249.output new file mode 100644 index 00000000..551d7011 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1231to1249.output @@ -0,0 +1,47 @@ +// code fix layerMergeAllWithDependencies_fix output for range 1231 - 1249 +import { Effect, Layer, Context } from "effect" + +export class DbConnection extends Context.Service()("DbConnection", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class FileSystem extends Context.Service()("FileSystem", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class Cache extends Context.Service()("Cache", { + make: Effect.as(FileSystem.asEffect(), {}) +}) { + static Default = Layer.effect(this, this.make) +} +export class UserRepository extends Context.Service()("UserRepository", { + make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) +}) { + static Default = Layer.effect(this, this.make) +} + +const cachePassthrough = Layer.effect(Cache, Cache.asEffect()) + +export const shouldNotWarn = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default +) + +export const shouldNotWarn2 = Layer.mergeAll( + UserRepository.Default, + cachePassthrough +) + +export const shouldWarn = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default, + Cache.Default // <- this requires a DbConnection +) + +export const shouldWarn2 = Layer.mergeAll( + DbConnection.Default, + Cache.Default, // <- this requires a FileSystem, + UserRepository.Default // <- this requires a DbConnection +).pipe(Layer.provideMerge(FileSystem.Default)) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1253to1266.output b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1253to1266.output new file mode 100644 index 00000000..11f59493 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies.ts.layerMergeAllWithDependencies_fix.from1253to1266.output @@ -0,0 +1,47 @@ +// code fix layerMergeAllWithDependencies_fix output for range 1253 - 1266 +import { Effect, Layer, Context } from "effect" + +export class DbConnection extends Context.Service()("DbConnection", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class FileSystem extends Context.Service()("FileSystem", { + make: Effect.succeed({}) +}) { + static Default = Layer.effect(this, this.make) +} +export class Cache extends Context.Service()("Cache", { + make: Effect.as(FileSystem.asEffect(), {}) +}) { + static Default = Layer.effect(this, this.make) +} +export class UserRepository extends Context.Service()("UserRepository", { + make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) +}) { + static Default = Layer.effect(this, this.make) +} + +const cachePassthrough = Layer.effect(Cache, Cache.asEffect()) + +export const shouldNotWarn = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default +) + +export const shouldNotWarn2 = Layer.mergeAll( + UserRepository.Default, + cachePassthrough +) + +export const shouldWarn = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default, + Cache.Default // <- this requires a DbConnection +) + +export const shouldWarn2 = Layer.mergeAll( + DbConnection.Default, + FileSystem.Default, // <- this requires a FileSystem, + UserRepository.Default // <- this requires a DbConnection +).pipe(Layer.provideMerge(Cache.Default)) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies_preview.ts.codefixes index b5d97ebc..c4c4053d 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies_preview.ts.codefixes @@ -1,3 +1,3 @@ -layerMergeAllWithDependencies_fix from 445 to 454 -layerMergeAllWithDependencies_skipNextLine from 445 to 454 -layerMergeAllWithDependencies_skipFile from 445 to 454 \ No newline at end of file +layerMergeAllWithDependencies_fix from 436 to 445 +layerMergeAllWithDependencies_skipNextLine from 436 to 445 +layerMergeAllWithDependencies_skipFile from 436 to 445 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies_preview.ts.layerMergeAllWithDependencies_fix.from436to445.output b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies_preview.ts.layerMergeAllWithDependencies_fix.from436to445.output new file mode 100644 index 00000000..e61333b0 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/layerMergeAllWithDependencies_preview.ts.layerMergeAllWithDependencies_fix.from436to445.output @@ -0,0 +1,12 @@ +// code fix layerMergeAllWithDependencies_fix output for range 436 - 445 +// @effect-diagnostics *:off +// @effect-diagnostics layerMergeAllWithDependencies:warning +import { Effect, Layer, Context } from "effect" + +class A extends Context.Service()("A", { make: Effect.succeed({}) }) { + static Default = Layer.effect(this, this.make) +} +class B extends Context.Service()("B", { make: Effect.as(A.asEffect(), {}) }) { + static Default = Layer.effect(this, this.make) +} +export const preview = Layer.mergeAll( B.Default).pipe(Layer.provideMerge(A.Default)) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements.ts.codefixes index 23df9d54..3b9bfbb2 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements.ts.codefixes @@ -1,4 +1,4 @@ -leakingRequirements_skipNextLine from 229 to 240 -leakingRequirements_skipFile from 229 to 240 -leakingRequirements_skipNextLine from 595 to 608 -leakingRequirements_skipFile from 595 to 608 \ No newline at end of file +leakingRequirements_skipNextLine from 223 to 234 +leakingRequirements_skipFile from 223 to 234 +leakingRequirements_skipNextLine from 583 to 596 +leakingRequirements_skipFile from 583 to 596 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_allowJsdoc.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_allowJsdoc.ts.codefixes index 6a9ee761..311208ef 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_allowJsdoc.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_allowJsdoc.ts.codefixes @@ -1,2 +1,2 @@ -leakingRequirements_skipNextLine from 495 to 506 -leakingRequirements_skipFile from 495 to 506 \ No newline at end of file +leakingRequirements_skipNextLine from 486 to 497 +leakingRequirements_skipFile from 486 to 497 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.codefixes index 0f7803f9..e9c00c39 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.codefixes @@ -1,2 +1,2 @@ -leakingRequirements_skipNextLine from 383 to 435 -leakingRequirements_skipFile from 383 to 435 \ No newline at end of file +leakingRequirements_skipNextLine from 377 to 426 +leakingRequirements_skipFile from 377 to 426 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.output index f1d3a0cd..bdda692f 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_genericTag.ts.output @@ -1,5 +1,5 @@ -ServiceMap.Service("LeakingService") -13:26 - 13:78 | 2 | Methods of this Service require `FileSystem` from every caller. +Context.Service("LeakingService") +13:26 - 13:75 | 2 | Methods of this Service require `FileSystem` from every caller. The requirement becomes part of the public service surface instead of remaining internal to Layer implementation. diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_preview.ts.codefixes index 12b57a85..981f5dc5 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/leakingRequirements_preview.ts.codefixes @@ -1,2 +1,2 @@ -leakingRequirements_skipNextLine from 292 to 297 -leakingRequirements_skipFile from 292 to 297 \ No newline at end of file +leakingRequirements_skipNextLine from 286 to 291 +leakingRequirements_skipFile from 286 to 291 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_callExpression.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_callExpression.ts.codefixes index 7e8c0af1..7a5691e3 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_callExpression.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_callExpression.ts.codefixes @@ -1,4 +1,4 @@ -missingEffectContext_skipNextLine from 559 to 577 -missingEffectContext_skipFile from 559 to 577 -missingEffectContext_skipNextLine from 729 to 747 -missingEffectContext_skipFile from 729 to 747 \ No newline at end of file +missingEffectContext_skipNextLine from 547 to 565 +missingEffectContext_skipFile from 547 to 565 +missingEffectContext_skipNextLine from 717 to 735 +missingEffectContext_skipFile from 717 to 735 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_conciseBody.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_conciseBody.ts.codefixes index 398be423..0e29659b 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_conciseBody.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_conciseBody.ts.codefixes @@ -1,2 +1,2 @@ -missingEffectContext_skipNextLine from 307 to 325 -missingEffectContext_skipFile from 307 to 325 \ No newline at end of file +missingEffectContext_skipNextLine from 301 to 319 +missingEffectContext_skipFile from 301 to 319 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_lazy.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_lazy.ts.codefixes index 64e3b574..b26e0ad8 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_lazy.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_lazy.ts.codefixes @@ -1,2 +1,2 @@ -missingEffectContext_skipNextLine from 781 to 832 -missingEffectContext_skipFile from 781 to 832 \ No newline at end of file +missingEffectContext_skipNextLine from 775 to 826 +missingEffectContext_skipFile from 775 to 826 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_plainAssignment.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_plainAssignment.ts.codefixes index 21e87260..04ca014e 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_plainAssignment.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_plainAssignment.ts.codefixes @@ -1,10 +1,10 @@ -missingEffectContext_skipNextLine from 594 to 612 -missingEffectContext_skipFile from 594 to 612 -missingEffectContext_skipNextLine from 691 to 706 -missingEffectContext_skipFile from 691 to 706 -missingEffectContext_skipNextLine from 906 to 934 -missingEffectContext_skipFile from 906 to 934 -missingEffectContext_skipNextLine from 1213 to 1231 -missingEffectContext_skipFile from 1213 to 1231 -missingEffectContext_skipNextLine from 1075 to 1090 -missingEffectContext_skipFile from 1075 to 1090 \ No newline at end of file +missingEffectContext_skipNextLine from 582 to 600 +missingEffectContext_skipFile from 582 to 600 +missingEffectContext_skipNextLine from 679 to 694 +missingEffectContext_skipFile from 679 to 694 +missingEffectContext_skipNextLine from 894 to 922 +missingEffectContext_skipFile from 894 to 922 +missingEffectContext_skipNextLine from 1194 to 1212 +missingEffectContext_skipFile from 1194 to 1212 +missingEffectContext_skipNextLine from 1063 to 1078 +missingEffectContext_skipFile from 1063 to 1078 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_preview.ts.codefixes index d830e734..32689848 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_preview.ts.codefixes @@ -1,2 +1,2 @@ -missingEffectContext_skipNextLine from 241 to 248 -missingEffectContext_skipFile from 241 to 248 \ No newline at end of file +missingEffectContext_skipNextLine from 235 to 242 +missingEffectContext_skipFile from 235 to 242 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_returnSignature.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_returnSignature.ts.codefixes index 21867272..575c4aed 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_returnSignature.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingEffectContext_returnSignature.ts.codefixes @@ -1,6 +1,6 @@ -missingEffectContext_skipNextLine from 538 to 563 -missingEffectContext_skipFile from 538 to 563 -missingEffectContext_skipNextLine from 649 to 667 -missingEffectContext_skipFile from 649 to 667 -missingEffectContext_skipNextLine from 798 to 816 -missingEffectContext_skipFile from 798 to 816 \ No newline at end of file +missingEffectContext_skipNextLine from 526 to 551 +missingEffectContext_skipFile from 526 to 551 +missingEffectContext_skipNextLine from 637 to 655 +missingEffectContext_skipFile from 637 to 655 +missingEffectContext_skipNextLine from 786 to 804 +missingEffectContext_skipFile from 786 to 804 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext.ts.codefixes index 757bb80f..2e4b8629 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext.ts.codefixes @@ -1,4 +1,4 @@ -missingLayerContext_skipNextLine from 715 to 732 -missingLayerContext_skipFile from 715 to 732 -missingLayerContext_skipNextLine from 869 to 886 -missingLayerContext_skipFile from 869 to 886 \ No newline at end of file +missingLayerContext_skipNextLine from 703 to 720 +missingLayerContext_skipFile from 703 to 720 +missingLayerContext_skipNextLine from 857 to 874 +missingLayerContext_skipFile from 857 to 874 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext_preview.ts.codefixes index d85f74a1..92b76259 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/missingLayerContext_preview.ts.codefixes @@ -1,2 +1,2 @@ -missingLayerContext_skipNextLine from 339 to 346 -missingLayerContext_skipFile from 339 to 346 \ No newline at end of file +missingLayerContext_skipNextLine from 333 to 340 +missingLayerContext_skipFile from 333 to 340 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.codefixes index 9738f15f..9cfd6f1a 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.codefixes @@ -1,12 +1,12 @@ -multipleEffectProvide_fix from 604 to 638 -multipleEffectProvide_skipNextLine from 604 to 638 -multipleEffectProvide_skipFile from 604 to 638 -multipleEffectProvide_fix from 738 to 772 -multipleEffectProvide_skipNextLine from 738 to 772 -multipleEffectProvide_skipFile from 738 to 772 -multipleEffectProvide_fix from 831 to 865 -multipleEffectProvide_skipNextLine from 831 to 865 -multipleEffectProvide_skipFile from 831 to 865 -multipleEffectProvide_fix from 961 to 995 -multipleEffectProvide_skipNextLine from 961 to 995 -multipleEffectProvide_skipFile from 961 to 995 \ No newline at end of file +multipleEffectProvide_fix from 592 to 626 +multipleEffectProvide_skipNextLine from 592 to 626 +multipleEffectProvide_skipFile from 592 to 626 +multipleEffectProvide_fix from 726 to 760 +multipleEffectProvide_skipNextLine from 726 to 760 +multipleEffectProvide_skipFile from 726 to 760 +multipleEffectProvide_fix from 819 to 853 +multipleEffectProvide_skipNextLine from 819 to 853 +multipleEffectProvide_skipFile from 819 to 853 +multipleEffectProvide_fix from 949 to 983 +multipleEffectProvide_skipNextLine from 949 to 983 +multipleEffectProvide_skipFile from 949 to 983 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from592to626.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from592to626.output new file mode 100644 index 00000000..80527897 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from592to626.output @@ -0,0 +1,38 @@ +// code fix multipleEffectProvide_fix output for range 592 - 626 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +export const shouldReport = Effect.void.pipe( + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)) +) + +export const shouldReportSeparately = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.ignore, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportSingle = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from726to760.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from726to760.output new file mode 100644 index 00000000..80ad1f17 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from726to760.output @@ -0,0 +1,38 @@ +// code fix multipleEffectProvide_fix output for range 726 - 760 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +export const shouldReport = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportSeparately = Effect.void.pipe( + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)), + Effect.ignore, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportSingle = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from819to853.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from819to853.output new file mode 100644 index 00000000..a90dfb8b --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from819to853.output @@ -0,0 +1,38 @@ +// code fix multipleEffectProvide_fix output for range 819 - 853 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +export const shouldReport = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportSeparately = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.ignore, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)) +) + +export const shouldReportSingle = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from949to983.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from949to983.output new file mode 100644 index 00000000..abbec6f8 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide.ts.multipleEffectProvide_fix.from949to983.output @@ -0,0 +1,37 @@ +// code fix multipleEffectProvide_fix output for range 949 - 983 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +export const shouldReport = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportSeparately = Effect.void.pipe( + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.ignore, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportSingle = Effect.void.pipe( + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default, MyService3.Default)) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.codefixes index a334e2d8..43d2d03f 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.codefixes @@ -1,12 +1,12 @@ -multipleEffectProvide_fix from 697 to 731 -multipleEffectProvide_skipNextLine from 697 to 731 -multipleEffectProvide_skipFile from 697 to 731 -multipleEffectProvide_fix from 889 to 923 -multipleEffectProvide_skipNextLine from 889 to 923 -multipleEffectProvide_skipFile from 889 to 923 -multipleEffectProvide_fix from 1081 to 1115 -multipleEffectProvide_skipNextLine from 1081 to 1115 -multipleEffectProvide_skipFile from 1081 to 1115 -multipleEffectProvide_fix from 1262 to 1296 -multipleEffectProvide_skipNextLine from 1262 to 1296 -multipleEffectProvide_skipFile from 1262 to 1296 \ No newline at end of file +multipleEffectProvide_fix from 685 to 719 +multipleEffectProvide_skipNextLine from 685 to 719 +multipleEffectProvide_skipFile from 685 to 719 +multipleEffectProvide_fix from 877 to 911 +multipleEffectProvide_skipNextLine from 877 to 911 +multipleEffectProvide_skipFile from 877 to 911 +multipleEffectProvide_fix from 1069 to 1103 +multipleEffectProvide_skipNextLine from 1069 to 1103 +multipleEffectProvide_skipFile from 1069 to 1103 +multipleEffectProvide_fix from 1250 to 1284 +multipleEffectProvide_skipNextLine from 1250 to 1284 +multipleEffectProvide_skipFile from 1250 to 1284 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from1069to1103.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from1069to1103.output new file mode 100644 index 00000000..031539f3 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from1069to1103.output @@ -0,0 +1,53 @@ +// code fix multipleEffectProvide_fix output for range 1069 - 1103 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +// Effect.fn with multiple provide calls +export const shouldReportEffectFn = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnTraced = Effect.fn("traced")( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnUntraced = Effect.fnUntraced( + function*() { + return yield* Effect.void + }, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)) +) + +export const shouldReportThreeProvides = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from1250to1284.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from1250to1284.output new file mode 100644 index 00000000..ff7211c4 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from1250to1284.output @@ -0,0 +1,52 @@ +// code fix multipleEffectProvide_fix output for range 1250 - 1284 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +// Effect.fn with multiple provide calls +export const shouldReportEffectFn = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnTraced = Effect.fn("traced")( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnUntraced = Effect.fnUntraced( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportThreeProvides = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default, MyService3.Default)) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from685to719.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from685to719.output new file mode 100644 index 00000000..8e4c4463 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from685to719.output @@ -0,0 +1,53 @@ +// code fix multipleEffectProvide_fix output for range 685 - 719 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +// Effect.fn with multiple provide calls +export const shouldReportEffectFn = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)) +) + +export const shouldReportEffectFnTraced = Effect.fn("traced")( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnUntraced = Effect.fnUntraced( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportThreeProvides = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from877to911.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from877to911.output new file mode 100644 index 00000000..0098a691 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFn.ts.multipleEffectProvide_fix.from877to911.output @@ -0,0 +1,53 @@ +// code fix multipleEffectProvide_fix output for range 877 - 911 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +// Effect.fn with multiple provide calls +export const shouldReportEffectFn = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnTraced = Effect.fn("traced")( + function*() { + return yield* Effect.void + }, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)) +) + +export const shouldReportEffectFnUntraced = Effect.fnUntraced( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportThreeProvides = Effect.fn( + function*() { + return yield* Effect.void + }, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.codefixes index 2abcc1f6..ffa3b64e 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.codefixes @@ -1,9 +1,9 @@ -multipleEffectProvide_fix from 711 to 745 -multipleEffectProvide_skipNextLine from 711 to 745 -multipleEffectProvide_skipFile from 711 to 745 -multipleEffectProvide_fix from 880 to 914 -multipleEffectProvide_skipNextLine from 880 to 914 -multipleEffectProvide_skipFile from 880 to 914 -multipleEffectProvide_fix from 1038 to 1072 -multipleEffectProvide_skipNextLine from 1038 to 1072 -multipleEffectProvide_skipFile from 1038 to 1072 \ No newline at end of file +multipleEffectProvide_fix from 699 to 733 +multipleEffectProvide_skipNextLine from 699 to 733 +multipleEffectProvide_skipFile from 699 to 733 +multipleEffectProvide_fix from 868 to 902 +multipleEffectProvide_skipNextLine from 868 to 902 +multipleEffectProvide_skipFile from 868 to 902 +multipleEffectProvide_fix from 1026 to 1060 +multipleEffectProvide_skipNextLine from 1026 to 1060 +multipleEffectProvide_skipFile from 1026 to 1060 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from1026to1060.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from1026to1060.output new file mode 100644 index 00000000..f8e549ce --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from1026to1060.output @@ -0,0 +1,38 @@ +// code fix multipleEffectProvide_fix output for range 1026 - 1060 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +// Effect.fn with regular (non-generator) function and multiple provide calls +export const shouldReportEffectFnRegular = Effect.fn( + () => Effect.void, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnRegularTraced = Effect.fn("traced")( + () => Effect.void, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportThreeProvidesRegular = Effect.fn( + () => Effect.void, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default, MyService3.Default)) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from699to733.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from699to733.output new file mode 100644 index 00000000..34ecab64 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from699to733.output @@ -0,0 +1,39 @@ +// code fix multipleEffectProvide_fix output for range 699 - 733 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +// Effect.fn with regular (non-generator) function and multiple provide calls +export const shouldReportEffectFnRegular = Effect.fn( + () => Effect.void, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)) +) + +export const shouldReportEffectFnRegularTraced = Effect.fn("traced")( + () => Effect.void, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportThreeProvidesRegular = Effect.fn( + () => Effect.void, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from868to902.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from868to902.output new file mode 100644 index 00000000..993bee93 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_effectFnRegular.ts.multipleEffectProvide_fix.from868to902.output @@ -0,0 +1,39 @@ +// code fix multipleEffectProvide_fix output for range 868 - 902 +import { Context, Effect, Layer } from "effect" + +class MyService1 extends Context.Service()("MyService1", { + make: Effect.succeed({ value: 1 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService2 extends Context.Service()("MyService2", { + make: Effect.succeed({ value: 2 }) +}) { + static Default = Layer.effect(this, this.make) +} + +class MyService3 extends Context.Service()("MyService3", { + make: Effect.succeed({ value: 3 }) +}) { + static Default = Layer.effect(this, this.make) +} + +// Effect.fn with regular (non-generator) function and multiple provide calls +export const shouldReportEffectFnRegular = Effect.fn( + () => Effect.void, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default) +) + +export const shouldReportEffectFnRegularTraced = Effect.fn("traced")( + () => Effect.void, + Effect.provide(Layer.mergeAll(MyService1.Default, MyService2.Default)) +) + +export const shouldReportThreeProvidesRegular = Effect.fn( + () => Effect.void, + Effect.provide(MyService1.Default), + Effect.provide(MyService2.Default), + Effect.provide(MyService3.Default) +) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_preview.ts.codefixes index 42abdb10..d8f83826 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_preview.ts.codefixes @@ -1,3 +1,3 @@ -multipleEffectProvide_fix from 430 to 455 -multipleEffectProvide_skipNextLine from 430 to 455 -multipleEffectProvide_skipFile from 430 to 455 \ No newline at end of file +multipleEffectProvide_fix from 421 to 446 +multipleEffectProvide_skipNextLine from 421 to 446 +multipleEffectProvide_skipFile from 421 to 446 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_preview.ts.multipleEffectProvide_fix.from421to446.output b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_preview.ts.multipleEffectProvide_fix.from421to446.output new file mode 100644 index 00000000..71db009f --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/multipleEffectProvide_preview.ts.multipleEffectProvide_fix.from421to446.output @@ -0,0 +1,12 @@ +// code fix multipleEffectProvide_fix output for range 421 - 446 +// @effect-diagnostics *:off +// @effect-diagnostics multipleEffectProvide:warning +import { Effect, Layer, Context } from "effect" + +class A extends Context.Service()("A", { make: Effect.succeed({}) }) { + static Default = Layer.effect(this, this.make) +} +class B extends Context.Service()("B", { make: Effect.succeed({}) }) { + static Default = Layer.effect(this, this.make) +} +export const preview = Effect.void.pipe(Effect.provide(Layer.mergeAll(A.Default, B.Default))) diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect.ts.output index 3f64fc1a..37df7cc3 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect.ts.output @@ -2,4 +2,4 @@ Effect.runSync 14:20 - 14:34 | 2 | `Effect.runSync` is called inside an existing Effect context. Here, the inner Effect can be used directly. effect(runEffectInsideEffect) Effect.runPromise -22:4 - 22:21 | 2 | `Effect.runPromise` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through `Effect.services` and `Effect.runPromiseWith`. effect(runEffectInsideEffect) \ No newline at end of file +22:4 - 22:21 | 2 | `Effect.runPromise` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through `Effect.context` and `Effect.runPromiseWith`. effect(runEffectInsideEffect) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect_preview.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect_preview.ts.output index 7a108cc4..ebff3ab9 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect_preview.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/runEffectInsideEffect_preview.ts.output @@ -1,2 +1,2 @@ Effect.runSync -6:20 - 6:34 | 0 | `Effect.runSync` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through `Effect.services` and `Effect.runSyncWith`. effect(runEffectInsideEffect) \ No newline at end of file +6:20 - 6:34 | 0 | `Effect.runSync` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through `Effect.context` and `Effect.runSyncWith`. effect(runEffectInsideEffect) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.codefixes index 57319b20..0b14c6c1 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.codefixes @@ -1,6 +1,6 @@ -serviceNotAsClass from 180 to 223 -serviceNotAsClass_skipNextLine from 180 to 223 -serviceNotAsClass_skipFile from 180 to 223 -serviceNotAsClass from 348 to 413 -serviceNotAsClass_skipNextLine from 348 to 413 -serviceNotAsClass_skipFile from 348 to 413 \ No newline at end of file +serviceNotAsClass from 174 to 214 +serviceNotAsClass_skipNextLine from 174 to 214 +serviceNotAsClass_skipFile from 174 to 214 +serviceNotAsClass from 336 to 398 +serviceNotAsClass_skipNextLine from 336 to 398 +serviceNotAsClass_skipFile from 336 to 398 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.output index 9fbe5932..1131b7d4 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.output @@ -1,5 +1,5 @@ -ServiceMap.Service("Config") -7:15 - 7:58 | 0 | `ServiceMap.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class Config extends ServiceMap.Service()("Config") {}`. effect(serviceNotAsClass) +Context.Service("Config") +7:15 - 7:55 | 0 | `Context.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class Config extends Context.Service()("Config") {}`. effect(serviceNotAsClass) -ServiceMap.Service("@my-app/ArtifactStore") -11:29 - 11:94 | 0 | `ServiceMap.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class ArtifactStore extends ServiceMap.Service()("@my-app/ArtifactStore") {}`. effect(serviceNotAsClass) \ No newline at end of file +Context.Service("@my-app/ArtifactStore") +11:29 - 11:91 | 0 | `Context.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class ArtifactStore extends Context.Service()("@my-app/ArtifactStore") {}`. effect(serviceNotAsClass) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.serviceNotAsClass.from174to214.output b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.serviceNotAsClass.from174to214.output new file mode 100644 index 00000000..29dfc510 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.serviceNotAsClass.from174to214.output @@ -0,0 +1,18 @@ +// code fix serviceNotAsClass output for range 174 - 214 +// @effect-diagnostics serviceNotAsClass:warning +import { Context } from "effect" + +interface ConfigService {} + +// Flagged: const variable with Context.Service +class Config extends Context.Service()("Config") { } + +// Flagged: exported const variable with Context.Service +interface ArtifactStoreService {} +export const ArtifactStore = Context.Service("@my-app/ArtifactStore") + +// Not flagged: correct class extends form +class MyService extends Context.Service()("MyService") {} + +// Not flagged: non-Context.Service const +const x = 42 diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.serviceNotAsClass.from336to398.output b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.serviceNotAsClass.from336to398.output new file mode 100644 index 00000000..8a874136 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass.ts.serviceNotAsClass.from336to398.output @@ -0,0 +1,18 @@ +// code fix serviceNotAsClass output for range 336 - 398 +// @effect-diagnostics serviceNotAsClass:warning +import { Context } from "effect" + +interface ConfigService {} + +// Flagged: const variable with Context.Service +const Config = Context.Service("Config") + +// Flagged: exported const variable with Context.Service +interface ArtifactStoreService {} +export class ArtifactStore extends Context.Service()("@my-app/ArtifactStore") { } + +// Not flagged: correct class extends form +class MyService extends Context.Service()("MyService") {} + +// Not flagged: non-Context.Service const +const x = 42 diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.codefixes index eff4413b..dd2d1e1d 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.codefixes @@ -1,3 +1,3 @@ -serviceNotAsClass from 138 to 185 -serviceNotAsClass_skipNextLine from 138 to 185 -serviceNotAsClass_skipFile from 138 to 185 \ No newline at end of file +serviceNotAsClass from 135 to 179 +serviceNotAsClass_skipNextLine from 135 to 179 +serviceNotAsClass_skipFile from 135 to 179 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.output b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.output index 19a6132e..bc29593b 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.output +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.output @@ -1,2 +1,2 @@ -ServiceMap.Service<{ port: number }>("Preview") -5:23 - 5:70 | 0 | `ServiceMap.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class Preview extends ServiceMap.Service()("Preview") {}`. effect(serviceNotAsClass) \ No newline at end of file +Context.Service<{ port: number }>("Preview") +5:23 - 5:67 | 0 | `Context.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class Preview extends Context.Service()("Preview") {}`. effect(serviceNotAsClass) \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.serviceNotAsClass.from135to179.output b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.serviceNotAsClass.from135to179.output new file mode 100644 index 00000000..dd3470b0 --- /dev/null +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/serviceNotAsClass_preview.ts.serviceNotAsClass.from135to179.output @@ -0,0 +1,6 @@ +// code fix serviceNotAsClass output for range 135 - 179 +// @effect-diagnostics *:off +// @effect-diagnostics serviceNotAsClass:warning +import { Context } from "effect" + +export class Preview extends Context.Service()("Preview") { } diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide.ts.codefixes index 58efa429..19490e13 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide.ts.codefixes @@ -1,8 +1,8 @@ -strictEffectProvide_skipNextLine from 676 to 723 -strictEffectProvide_skipFile from 676 to 723 -strictEffectProvide_skipNextLine from 534 to 568 -strictEffectProvide_skipFile from 534 to 568 -strictEffectProvide_skipNextLine from 842 to 876 -strictEffectProvide_skipFile from 842 to 876 -strictEffectProvide_skipNextLine from 1000 to 1070 -strictEffectProvide_skipFile from 1000 to 1070 \ No newline at end of file +strictEffectProvide_skipNextLine from 667 to 714 +strictEffectProvide_skipFile from 667 to 714 +strictEffectProvide_skipNextLine from 525 to 559 +strictEffectProvide_skipFile from 525 to 559 +strictEffectProvide_skipNextLine from 833 to 867 +strictEffectProvide_skipFile from 833 to 867 +strictEffectProvide_skipNextLine from 991 to 1061 +strictEffectProvide_skipFile from 991 to 1061 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide_preview.ts.codefixes b/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide_preview.ts.codefixes index 1ed0b215..d6286e0a 100644 --- a/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide_preview.ts.codefixes +++ b/packages/harness-effect-v4/__snapshots__/diagnostics/strictEffectProvide_preview.ts.codefixes @@ -1,2 +1,2 @@ -strictEffectProvide_skipNextLine from 315 to 345 -strictEffectProvide_skipFile from 315 to 345 \ No newline at end of file +strictEffectProvide_skipNextLine from 309 to 339 +strictEffectProvide_skipFile from 309 to 339 \ No newline at end of file diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln26col23.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln26col23.output index ca557d49..947e924f 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln26col23.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln26col23.output @@ -1,23 +1,23 @@ // Result of running refactor layerMagic at position 26:23 -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) static bothInAndOut = Layer.effect(FileSystem, FileSystem.asEffect()) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln31col23.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln31col23.output index a3dabd0f..9233a296 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln31col23.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln31col23.output @@ -1,23 +1,23 @@ // Result of running refactor layerMagic at position 31:23 -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) static bothInAndOut = Layer.effect(FileSystem, FileSystem.asEffect()) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln38col24.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln38col24.output index 3be28c08..efe5c786 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln38col24.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln38col24.output @@ -1,23 +1,23 @@ // Result of running refactor layerMagic at position 38:24 -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) static bothInAndOut = Layer.effect(FileSystem, FileSystem.asEffect()) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln45col23.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln45col23.output index ffc866e8..0c371fb9 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln45col23.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln45col23.output @@ -1,23 +1,23 @@ // Result of running refactor layerMagic at position 45:23 -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) static bothInAndOut = Layer.effect(FileSystem, FileSystem.asEffect()) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln49col23.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln49col23.output index 2271b46a..f0931817 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln49col23.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln49col23.output @@ -1,23 +1,23 @@ // Result of running refactor layerMagic at position 49:23 -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) static bothInAndOut = Layer.effect(FileSystem, FileSystem.asEffect()) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln51col23.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln51col23.output index c7a90e02..267f2674 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln51col23.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_build.ts.ln51col23.output @@ -1,23 +1,23 @@ // Result of running refactor layerMagic at position 51:23 -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) static bothInAndOut = Layer.effect(FileSystem, FileSystem.asEffect()) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln25col20.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln25col20.output index 36398948..d97ca3e6 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln25col20.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln25col20.output @@ -1,22 +1,22 @@ // Result of running refactor layerMagic at position 25:20 -import { Effect, Layer, pipe, ServiceMap } from "effect" +import { Effect, Layer, pipe, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln27col20.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln27col20.output index 750d758d..b51a62d6 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln27col20.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln27col20.output @@ -1,22 +1,22 @@ // Result of running refactor layerMagic at position 27:20 -import { Effect, Layer, pipe, ServiceMap } from "effect" +import { Effect, Layer, pipe, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln32col20.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln32col20.output index 0f4e6afe..35a5f27d 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln32col20.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepare.ts.ln32col20.output @@ -1,22 +1,22 @@ // Result of running refactor layerMagic at position 32:20 -import { Effect, Layer, pipe, ServiceMap } from "effect" +import { Effect, Layer, pipe, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln25col20.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln25col20.output index e57b51b6..2ce3c5bf 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln25col20.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln25col20.output @@ -1,22 +1,22 @@ // Result of running refactor layerMagic at position 25:20 -import { Effect, Layer, pipe, ServiceMap } from "effect" +import { Effect, Layer, pipe, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln31col20.output b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln31col20.output index bcb82458..b581cf7e 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln31col20.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/layerMagic_prepareReuse.ts.ln31col20.output @@ -1,22 +1,22 @@ // Result of running refactor layerMagic at position 31:20 -import { Effect, Layer, pipe, ServiceMap } from "effect" +import { Effect, Layer, pipe, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln11col18.output b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln11col18.output index 09fd2034..28ea2540 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln11col18.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln11col18.output @@ -6,7 +6,7 @@ export interface Service {} export const simple = Effect.succeed(true) export const simpleFailure = Effect.fail("Hello") -export const simpleRequire = Effect.services() +export const simpleRequire = Effect.context() export const inUnion: Effect.Effect | Effect.Effect = Math.random() > 0.1 ? Effect.succeed(true) : Effect.succeed(42) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln13col18.output b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln13col18.output index dd14bb5e..abf2d9d9 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln13col18.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln13col18.output @@ -6,7 +6,7 @@ export interface Service {} export const simple = Effect.succeed(true) export const simpleFailure = Effect.fail("Hello") -export const simpleRequire = Effect.services() +export const simpleRequire = Effect.context() export const inUnion = Math.random() > 0.1 ? Effect.succeed(true) : Effect.succeed(42) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln19col18.output b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln19col18.output index d95e7a8d..c99d0f7d 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln19col18.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln19col18.output @@ -6,7 +6,7 @@ export interface Service {} export const simple = Effect.succeed(true) export const simpleFailure = Effect.fail("Hello") -export const simpleRequire = Effect.services() +export const simpleRequire = Effect.context() export const inUnion = Math.random() > 0.1 ? Effect.succeed(true) : Effect.succeed(42) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln7col18.output b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln7col18.output index 1d58768c..f9b66527 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln7col18.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln7col18.output @@ -6,7 +6,7 @@ export interface Service {} export const simple: Effect.Effect = Effect.succeed(true) export const simpleFailure = Effect.fail("Hello") -export const simpleRequire = Effect.services() +export const simpleRequire = Effect.context() export const inUnion = Math.random() > 0.1 ? Effect.succeed(true) : Effect.succeed(42) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln8col17.output b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln8col17.output index 73f27c1a..f9b8ce1e 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln8col17.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln8col17.output @@ -6,7 +6,7 @@ export interface Service {} export const simple = Effect.succeed(true) export const simpleFailure: Effect.Effect = Effect.fail("Hello") -export const simpleRequire = Effect.services() +export const simpleRequire = Effect.context() export const inUnion = Math.random() > 0.1 ? Effect.succeed(true) : Effect.succeed(42) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln9col18.output b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln9col18.output index b64a8c40..9de12462 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln9col18.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_simplify.ts.ln9col18.output @@ -6,7 +6,7 @@ export interface Service {} export const simple = Effect.succeed(true) export const simpleFailure = Effect.fail("Hello") -export const simpleRequire: Effect.Effect, never, Service> = Effect.services() +export const simpleRequire: Effect.Effect, never, Service> = Effect.context() export const inUnion = Math.random() > 0.1 ? Effect.succeed(true) : Effect.succeed(42) diff --git a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_unnamed.ts.ln4col15.output b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_unnamed.ts.ln4col15.output index d640d2bf..1d32982d 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_unnamed.ts.ln4col15.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/toggleTypeAnnotation_unnamed.ts.ln4col15.output @@ -3,4 +3,4 @@ import * as Schema from "effect/Schema" export const debug: (input: { readonly id: import("node_modules/effect/dist/Option", { with: { "resolution-mode": "import" } }).Option }, options?: Schema.MakeOptions) => { readonly id: import("node_modules/effect/dist/Option", { with: { "resolution-mode": "import" } }).Option } = Schema.Struct({ id: Schema.Option(Schema.Number) -}).makeUnsafe +}).make diff --git a/packages/harness-effect-v4/__snapshots__/refactors/wrapWithEffectGen_noclass.ts.ln4col36.output b/packages/harness-effect-v4/__snapshots__/refactors/wrapWithEffectGen_noclass.ts.ln4col36.output index cbb6c1a8..93c30684 100644 --- a/packages/harness-effect-v4/__snapshots__/refactors/wrapWithEffectGen_noclass.ts.ln4col36.output +++ b/packages/harness-effect-v4/__snapshots__/refactors/wrapWithEffectGen_noclass.ts.ln4col36.output @@ -1,6 +1,6 @@ // Result of running refactor wrapWithEffectGen at position 4:36 -import { Effect, ServiceMap } from "effect" +import { Effect, Context } from "effect" -export class Asd extends ServiceMap.Service()("Asd", { +export class Asd extends Context.Service()("Asd", { make: Effect.succeed({}) }) {} diff --git a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses.ts b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses.ts index 62948a54..8d27dd30 100644 --- a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses.ts +++ b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses.ts @@ -1,4 +1,4 @@ -// 4:43 -import * as ServiceMap from "effect/ServiceMap" +// 4:40 +import * as Context from "effect/Context" -export class MyService extends ServiceMap. +export class MyService extends Context. diff --git a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_directImportService.ts b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_directImportService.ts index 7372b99d..5b80e87e 100644 --- a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_directImportService.ts +++ b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_directImportService.ts @@ -1,4 +1,4 @@ // 4:39 -import { Service } from "effect/ServiceMap" +import { Service } from "effect/Context" export class MyService extends Service diff --git a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_identifierKey.ts b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_identifierKey.ts index 456e6e2f..ac3d0321 100644 --- a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_identifierKey.ts +++ b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_identifierKey.ts @@ -1,5 +1,5 @@ -// 5:43 +// 5:40 // @test-config { "keyPatterns": [ { "pattern": "package-identifier", "target": "service" } ] } -import * as ServiceMap from "effect/ServiceMap" +import * as Context from "effect/Context" -export class MyService extends ServiceMap. +export class MyService extends Context. diff --git a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_middle.ts b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_middle.ts index bc4446ce..10a26b43 100644 --- a/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_middle.ts +++ b/packages/harness-effect-v4/examples/completions/serviceMapSelfInClasses_middle.ts @@ -1,7 +1,7 @@ -// 4:31 -import { Effect, ServiceMap, Stream } from "effect" +// 4:28 +import { Effect, Context, Stream } from "effect" -class Foo extends ServiceMap.S +class Foo extends Context.S Stream.unwrap(Effect.gen(function*() { const a = yield* Foo diff --git a/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext.ts b/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext.ts index 4b112c05..119aad2e 100644 --- a/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext.ts +++ b/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext.ts @@ -2,11 +2,11 @@ import { Effect, Layer } from "effect" export const withUnknownContext = Effect.gen(function*() { - yield* Effect.services() + yield* Effect.context() }) export const withAnyContext = Effect.gen(function*() { - yield* Effect.services() + yield* Effect.context() }) export const withAnyFailure = Effect.gen(function*() { @@ -18,7 +18,7 @@ export const withUnknownFailure = Effect.gen(function*() { }) export const hasBothAnyUnknown = Effect.gen(function*() { - yield* Effect.services() + yield* Effect.context() return yield* Effect.fail(42) }) @@ -34,6 +34,6 @@ export class Test { a: Effect.Effect = Effect.succeed(42) } -const effectUnkown = Effect.services() +const effectUnkown = Effect.context() const layerUnknown = Layer.effectDiscard(effectUnkown) export const composedLayerUnknown = Layer.empty.pipe(Layer.provide(layerUnknown)) diff --git a/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext_preview.ts b/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext_preview.ts index d03f0fe2..167803f7 100644 --- a/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/anyUnknownInErrorContext_preview.ts @@ -3,6 +3,6 @@ import { Effect } from "effect" export const preview = Effect.gen(function*() { - yield* Effect.services() + yield* Effect.context() return yield* Effect.fail("boom") }) diff --git a/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_contextTag.ts b/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_contextTag.ts index 177743e2..0171d5b2 100644 --- a/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_contextTag.ts +++ b/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_contextTag.ts @@ -1,11 +1,11 @@ -import {ServiceMap} from "effect" +import {Context} from "effect" interface ServiceShape { value: number } // valid usage: is correct because the Self type parameter is the same as the class name -export class ValidContextTag extends ServiceMap.Service()("ValidContextTag"){} +export class ValidContextTag extends Context.Service()("ValidContextTag"){} // invalid usage: should be because the Self type parameter is not the same as the class name -export class InvalidContextTag extends ServiceMap.Service()("InvalidContextTag"){} +export class InvalidContextTag extends Context.Service()("InvalidContextTag"){} diff --git a/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_service.ts b/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_service.ts index 8b834e89..64b8de21 100644 --- a/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_service.ts +++ b/packages/harness-effect-v4/examples/diagnostics/classSelfMismatch_service.ts @@ -1,11 +1,11 @@ -import { ServiceMap, Effect } from "effect" +import { Context, Effect } from "effect" -export class CorrectName extends ServiceMap.Service Effect.Effect readCache: Effect.Effect }>()("CorrectName") {} -export class WrongName extends ServiceMap.Service Effect.Effect readCache: Effect.Effect }>()("WrongName") {} diff --git a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys.ts b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys.ts index 6f1c474b..a3d8aa96 100644 --- a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys.ts +++ b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys.ts @@ -1,9 +1,9 @@ // @effect-diagnostics deterministicKeys:error // @test-config { "keyPatterns": [ { "target": "service", "pattern": "default" }, { "target": "error", "pattern": "default" } ] } -import { ServiceMap, Data } from "effect" +import { Context, Data } from "effect" export class ExpectedServiceIdentifier - extends ServiceMap.Service()("ExpectedServiceIdentifier") + extends Context.Service()("ExpectedServiceIdentifier") {} export class ErrorA extends Data.TaggedError("ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_custom.ts b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_custom.ts index 7f810485..5549dc69 100644 --- a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_custom.ts +++ b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_custom.ts @@ -1,11 +1,11 @@ // @effect-diagnostics deterministicKeys:error // @test-config { "extendedKeyDetection": true } import * as Persistable from "@/diagnostics/utils" -import { ServiceMap } from "effect" +import { Context } from "effect" // simple case inside same file export function MyConstructor(/** @effect-identifier */ identifier: string) { - return class extends ServiceMap.Service()("hey/" + identifier) {} + return class extends Context.Service()("hey/" + identifier) {} } export class MyClass extends MyConstructor("Hello") { diff --git a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_defaultHashed.ts b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_defaultHashed.ts index 2bf2f219..6e7b13b5 100644 --- a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_defaultHashed.ts +++ b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_defaultHashed.ts @@ -1,9 +1,9 @@ // @effect-diagnostics deterministicKeys:error // @test-config { "keyPatterns": [ { "target": "service", "pattern": "default-hashed" }, { "target": "error", "pattern": "default-hashed" } ] } -import { ServiceMap, Data } from "effect" +import { Context, Data } from "effect" export class ExpectedServiceIdentifier - extends ServiceMap.Service()("ExpectedServiceIdentifier") + extends Context.Service()("ExpectedServiceIdentifier") {} export class ErrorA extends Data.TaggedError("ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_packageIdentifier.ts b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_packageIdentifier.ts index c19ceb2a..13cc9e81 100644 --- a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_packageIdentifier.ts +++ b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_packageIdentifier.ts @@ -1,9 +1,9 @@ // @effect-diagnostics deterministicKeys:error // @test-config { "keyPatterns": [ { "target": "service", "pattern": "package-identifier" }, { "target": "error", "pattern": "package-identifier" } ] } -import { ServiceMap, Data } from "effect" +import { Context, Data } from "effect" export class ExpectedServiceIdentifier - extends ServiceMap.Service()("ExpectedServiceIdentifier") + extends Context.Service()("ExpectedServiceIdentifier") {} export class ErrorA extends Data.TaggedError("ErrorA")<{}> {} diff --git a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_preview.ts b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_preview.ts index 81976820..51c18198 100644 --- a/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/deterministicKeys_preview.ts @@ -1,7 +1,7 @@ // @effect-diagnostics *:off // @effect-diagnostics deterministicKeys:warning // @test-config { "keyPatterns": [{ "target": "service", "pattern": "default" }] } -import { ServiceMap } from "effect" +import { Context } from "effect" export class RenamedService - extends ServiceMap.Service()("CustomIdentifier") {} + extends Context.Service()("CustomIdentifier") {} diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayer.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayer.ts index 6b667594..7841a37e 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayer.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayer.ts @@ -1,7 +1,7 @@ // @test-config { "effectFn": ["inferred-span"] } -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class MyService extends ServiceMap.Service Effect.Effect }>()("MyService") {} diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayerThis.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayerThis.ts index 4f8a7c9e..1468ea64 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayerThis.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredLayerThis.ts @@ -1,7 +1,7 @@ // @test-config { "effectFn": ["inferred-span"] } -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -export class MyService extends ServiceMap.Service Effect.Effect }>()("MyService") { static layer = Layer.effect(this, Effect.gen(function*() { diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredOf.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredOf.ts index 3ebd7408..4de2efe4 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredOf.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredOf.ts @@ -1,7 +1,7 @@ // @test-config { "effectFn": ["inferred-span"] } -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class UserService extends ServiceMap.Service }>()("UserService") {} diff --git a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredServiceMake.ts b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredServiceMake.ts index eae183b6..3248f461 100644 --- a/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredServiceMake.ts +++ b/packages/harness-effect-v4/examples/diagnostics/effectFnOpportunity_inferredServiceMake.ts @@ -1,7 +1,7 @@ // @test-config { "effectFn": ["inferred-span"] } -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -export class UserService extends ServiceMap.Service()("UserService", { +export class UserService extends Context.Service()("UserService", { make: Effect.gen(function*() { return { getUser: (id: string) => diff --git a/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies.ts b/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies.ts index e1e2ffb1..985aaec6 100644 --- a/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies.ts +++ b/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies.ts @@ -1,21 +1,21 @@ -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -export class DbConnection extends ServiceMap.Service()("DbConnection", { +export class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -export class FileSystem extends ServiceMap.Service()("FileSystem", { +export class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -export class Cache extends ServiceMap.Service()("Cache", { +export class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -export class UserRepository extends ServiceMap.Service()("UserRepository", { +export class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies_preview.ts b/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies_preview.ts index 0234b85d..d045be59 100644 --- a/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/layerMergeAllWithDependencies_preview.ts @@ -1,11 +1,11 @@ // @effect-diagnostics *:off // @effect-diagnostics layerMergeAllWithDependencies:warning -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class A extends ServiceMap.Service()("A", { make: Effect.succeed({}) }) { +class A extends Context.Service()("A", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class B extends ServiceMap.Service()("B", { make: Effect.as(A.asEffect(), {}) }) { +class B extends Context.Service()("B", { make: Effect.as(A.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } export const preview = Layer.mergeAll(A.Default, B.Default) diff --git a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements.ts b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements.ts index ae19ccd5..5c92a3a2 100644 --- a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements.ts +++ b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements.ts @@ -1,21 +1,21 @@ import type { Effect } from "effect" -import { ServiceMap } from "effect" +import { Context } from "effect" -export class FileSystem extends ServiceMap.Service Effect.Effect }>()("FileSystem") {} -export class LeakingDeps extends ServiceMap.Service Effect.Effect readCache: Effect.Effect }>()("LeakingDeps") {} export function local() { - class _LocalClass extends ServiceMap.Service<_LocalClass, { + class _LocalClass extends Context.Service<_LocalClass, { writeFile: (content: string) => Effect.Effect }>()("LocalClass") {} - class _LocalLeaking extends ServiceMap.Service<_LocalLeaking, { + class _LocalLeaking extends Context.Service<_LocalLeaking, { writeCache: () => Effect.Effect readCache: Effect.Effect }>()("LocalLeaking") {} diff --git a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_allowJsdoc.ts b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_allowJsdoc.ts index a0a0a2e6..0e15adb0 100644 --- a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_allowJsdoc.ts +++ b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_allowJsdoc.ts @@ -1,18 +1,18 @@ import type { Effect } from "effect" -import { ServiceMap } from "effect" +import { Context } from "effect" -export class FileSystem extends ServiceMap.Service Effect.Effect }>()("FileSystem") {} -export class Cache extends ServiceMap.Service Effect.Effect }>()("Cache") {} // LeakingDeps is leaking FileSystem and Cache, but only Cache should be considered to be leaked // @effect-expect-leaking FileSystem -export class LeakingDeps extends ServiceMap.Service Effect.Effect readCache: Effect.Effect }>()("LeakingDeps") {} @@ -20,7 +20,7 @@ export class LeakingDeps extends ServiceMap.Service Effect.Effect readCache: Effect.Effect }>()("LeakingDeps2") {} @@ -32,7 +32,7 @@ export class LeakingDeps2 extends ServiceMap.Service Effect.Effect readCache: Effect.Effect }>()("LeakingDeps3") {} @@ -40,7 +40,7 @@ export class LeakingDeps3 extends ServiceMap.Service Effect.Effect readCache: Effect.Effect }>("LeakingDeps4") diff --git a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_genericTag.ts b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_genericTag.ts index 7af1b223..a406876b 100644 --- a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_genericTag.ts +++ b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_genericTag.ts @@ -1,7 +1,7 @@ import type { Effect } from "effect" -import { ServiceMap } from "effect" +import { Context } from "effect" -export class FileSystem extends ServiceMap.Service Effect.Effect }>()("FileSystem") {} @@ -10,4 +10,4 @@ interface LeakingService { readCache: Effect.Effect } -export const GenericTag = ServiceMap.Service("LeakingService") +export const GenericTag = Context.Service("LeakingService") diff --git a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_heuristic.ts b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_heuristic.ts index 73348ad2..e262b554 100644 --- a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_heuristic.ts +++ b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_heuristic.ts @@ -1,11 +1,11 @@ import type { Effect } from "effect" -import { ServiceMap } from "effect" +import { Context } from "effect" -export class FileSystem extends ServiceMap.Service Effect.Effect }>()("FileSystem") {} -export class ValidTag extends ServiceMap.Service writeCache: () => Effect.Effect readCache: Effect.Effect diff --git a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_leakableJsDoc.ts b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_leakableJsDoc.ts index c9c03207..621ac51c 100644 --- a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_leakableJsDoc.ts +++ b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_leakableJsDoc.ts @@ -1,10 +1,10 @@ import type { Effect } from "effect" -import { ServiceMap } from "effect" +import { Context } from "effect" /** * @effect-leakable-service */ -export class FileSystem extends ServiceMap.Service Effect.Effect }>()("FileSystem") { } @@ -14,4 +14,4 @@ interface LeakingService { readCache: Effect.Effect } -export const GenericTag = ServiceMap.Service("LeakingService") +export const GenericTag = Context.Service("LeakingService") diff --git a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_noScope.ts b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_noScope.ts index aacf62c7..bd39f58d 100644 --- a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_noScope.ts +++ b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_noScope.ts @@ -1,8 +1,8 @@ -import { ServiceMap } from "effect" +import { Context } from "effect" import type * as Effect from "effect/Effect" import type * as Scope from "effect/Scope" -export class FileSystem extends ServiceMap.Service Effect.Effect }>()("FileSystem") {} @@ -11,4 +11,4 @@ interface LeakingScopeIsFine { readCache: Effect.Effect } -export const GenericTag = ServiceMap.Service("LeakingScopeIsFine") +export const GenericTag = Context.Service("LeakingScopeIsFine") diff --git a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_preview.ts b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_preview.ts index 9f003f0f..7a7f3cb8 100644 --- a/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/leakingRequirements_preview.ts @@ -1,13 +1,13 @@ // @effect-diagnostics *:off // @effect-diagnostics leakingRequirements:warning import type { Effect } from "effect" -import { ServiceMap } from "effect" +import { Context } from "effect" -class FileSystem extends ServiceMap.Service Effect.Effect }>()("FileSystem") {} -export class Cache extends ServiceMap.Service save: () => Effect.Effect }>()("Cache") {} diff --git a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_callExpression.ts b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_callExpression.ts index 6d13be5c..ec5ac5ed 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_callExpression.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_callExpression.ts @@ -1,14 +1,14 @@ -import { Effect, ServiceMap} from "effect" +import { Effect, Context} from "effect" -class ServiceA extends ServiceMap.Service()("ServiceA", { +class ServiceA extends Context.Service()("ServiceA", { make: Effect.succeed({ a: 1 }) }) {} -class ServiceB extends ServiceMap.Service()("ServiceB", { +class ServiceB extends Context.Service()("ServiceB", { make: Effect.succeed({ a: 2 }) }) {} -class ServiceC extends ServiceMap.Service()("ServiceC", { +class ServiceC extends Context.Service()("ServiceC", { make: Effect.succeed({ a: 3 }) }) {} diff --git a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_conciseBody.ts b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_conciseBody.ts index c8674555..691a73d1 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_conciseBody.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_conciseBody.ts @@ -1,6 +1,6 @@ -import {Effect, ServiceMap} from "effect" +import {Effect, Context} from "effect" -class ServiceA extends ServiceMap.Service()("ServiceA", { +class ServiceA extends Context.Service()("ServiceA", { make: Effect.succeed({ a: 1 }) }) {} diff --git a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_lazy.ts b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_lazy.ts index 63d3b6c2..1ce7e410 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_lazy.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_lazy.ts @@ -1,6 +1,6 @@ -import {Effect, ServiceMap} from "effect" +import {Effect, Context} from "effect" -class ServiceA extends ServiceMap.Service()("ServiceA", { +class ServiceA extends Context.Service()("ServiceA", { make: Effect.succeed({ a: 1 }) }) {} diff --git a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_pipe.ts b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_pipe.ts index de65aacf..3c4f9687 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_pipe.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_pipe.ts @@ -1,7 +1,7 @@ -import {Effect, ServiceMap} from "effect" +import {Effect, Context} from "effect" import { pipe } from "effect/Function" -class ServiceA extends ServiceMap.Service()("ServiceA", { +class ServiceA extends Context.Service()("ServiceA", { make: Effect.succeed({ a: 1 }) }) {} diff --git a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_plainAssignment.ts b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_plainAssignment.ts index 6d7078ac..c5de4a20 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_plainAssignment.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_plainAssignment.ts @@ -1,15 +1,15 @@ -import { ServiceMap} from "effect" +import { Context} from "effect" import * as Effect from "effect/Effect" -class ServiceA extends ServiceMap.Service()("ServiceA", { +class ServiceA extends Context.Service()("ServiceA", { make: Effect.succeed({ a: 1 }) }) {} -class ServiceB extends ServiceMap.Service()("ServiceB", { +class ServiceB extends Context.Service()("ServiceB", { make: Effect.succeed({ a: 2 }) }) {} -class ServiceC extends ServiceMap.Service()("ServiceC", { +class ServiceC extends Context.Service()("ServiceC", { make: Effect.succeed({ a: 3 }) }) {} @@ -30,7 +30,7 @@ export const missingServiceCWithSubtyping: EffectSubtyping = effectWithS export function missingServiceWithGenericType(service: A) { // @ts-expect-error - const missingServiceA: Effect.Effect> = Effect.services() + const missingServiceA: Effect.Effect> = Effect.context() return missingServiceA } diff --git a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_preview.ts b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_preview.ts index 70500ec3..5a81e7d6 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_preview.ts @@ -1,8 +1,8 @@ // @effect-diagnostics *:off // @effect-diagnostics missingEffectContext:warning -import { Effect, ServiceMap } from "effect" +import { Effect, Context } from "effect" -class Db extends ServiceMap.Service()("Db", { make: Effect.succeed({}) }) {} +class Db extends Context.Service()("Db", { make: Effect.succeed({}) }) {} // @ts-expect-error export const preview: Effect.Effect = Db.asEffect().pipe(Effect.asVoid) diff --git a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_returnSignature.ts b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_returnSignature.ts index 59236ec4..25c364ec 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_returnSignature.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingEffectContext_returnSignature.ts @@ -1,14 +1,14 @@ -import { Effect, ServiceMap} from "effect" +import { Effect, Context} from "effect" -class ServiceA extends ServiceMap.Service()("ServiceA", { +class ServiceA extends Context.Service()("ServiceA", { make: Effect.succeed({ a: 1 }) }) {} -class ServiceB extends ServiceMap.Service()("ServiceB", { +class ServiceB extends Context.Service()("ServiceB", { make: Effect.succeed({ a: 2 }) }) {} -class ServiceC extends ServiceMap.Service()("ServiceC", { +class ServiceC extends Context.Service()("ServiceC", { make: Effect.succeed({ a: 3 }) }) {} diff --git a/packages/harness-effect-v4/examples/diagnostics/missingLayerContext.ts b/packages/harness-effect-v4/examples/diagnostics/missingLayerContext.ts index c2a636ec..d0e5390b 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingLayerContext.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingLayerContext.ts @@ -1,18 +1,18 @@ -import { ServiceMap, Effect, Layer } from "effect" +import { Context, Effect, Layer } from "effect" -class ServiceA extends ServiceMap.Service()("ServiceA", { +class ServiceA extends Context.Service()("ServiceA", { make: Effect.succeed({ value: 1 }) }) { static Default = Layer.effect(this, this.make) } -class ServiceB extends ServiceMap.Service()("ServiceB", { +class ServiceB extends Context.Service()("ServiceB", { make: Effect.succeed({ value: 2 }) }) { static Default = Layer.effect(this, this.make) } -class ServiceC extends ServiceMap.Service()("ServiceC", { +class ServiceC extends Context.Service()("ServiceC", { make: Effect.succeed({ value: 3 }) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/diagnostics/missingLayerContext_preview.ts b/packages/harness-effect-v4/examples/diagnostics/missingLayerContext_preview.ts index b2e8f624..bf9a4cfa 100644 --- a/packages/harness-effect-v4/examples/diagnostics/missingLayerContext_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/missingLayerContext_preview.ts @@ -1,8 +1,8 @@ // @effect-diagnostics *:off // @effect-diagnostics missingLayerContext:warning -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class A extends ServiceMap.Service()("A", { make: Effect.succeed({}) }) { +class A extends Context.Service()("A", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } declare const layer: Layer.Layer diff --git a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide.ts b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide.ts index 1f334d63..420d60c5 100644 --- a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide.ts +++ b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide.ts @@ -1,18 +1,18 @@ -import { ServiceMap, Effect, Layer } from "effect" +import { Context, Effect, Layer } from "effect" -class MyService1 extends ServiceMap.Service()("MyService1", { +class MyService1 extends Context.Service()("MyService1", { make: Effect.succeed({ value: 1 }) }) { static Default = Layer.effect(this, this.make) } -class MyService2 extends ServiceMap.Service()("MyService2", { +class MyService2 extends Context.Service()("MyService2", { make: Effect.succeed({ value: 2 }) }) { static Default = Layer.effect(this, this.make) } -class MyService3 extends ServiceMap.Service()("MyService3", { +class MyService3 extends Context.Service()("MyService3", { make: Effect.succeed({ value: 3 }) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFn.ts b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFn.ts index 4e09ca2d..4b1fedf6 100644 --- a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFn.ts +++ b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFn.ts @@ -1,18 +1,18 @@ -import { ServiceMap, Effect, Layer } from "effect" +import { Context, Effect, Layer } from "effect" -class MyService1 extends ServiceMap.Service()("MyService1", { +class MyService1 extends Context.Service()("MyService1", { make: Effect.succeed({ value: 1 }) }) { static Default = Layer.effect(this, this.make) } -class MyService2 extends ServiceMap.Service()("MyService2", { +class MyService2 extends Context.Service()("MyService2", { make: Effect.succeed({ value: 2 }) }) { static Default = Layer.effect(this, this.make) } -class MyService3 extends ServiceMap.Service()("MyService3", { +class MyService3 extends Context.Service()("MyService3", { make: Effect.succeed({ value: 3 }) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFnRegular.ts b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFnRegular.ts index fa33d28b..842b6088 100644 --- a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFnRegular.ts +++ b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_effectFnRegular.ts @@ -1,18 +1,18 @@ -import { ServiceMap, Effect, Layer } from "effect" +import { Context, Effect, Layer } from "effect" -class MyService1 extends ServiceMap.Service()("MyService1", { +class MyService1 extends Context.Service()("MyService1", { make: Effect.succeed({ value: 1 }) }) { static Default = Layer.effect(this, this.make) } -class MyService2 extends ServiceMap.Service()("MyService2", { +class MyService2 extends Context.Service()("MyService2", { make: Effect.succeed({ value: 2 }) }) { static Default = Layer.effect(this, this.make) } -class MyService3 extends ServiceMap.Service()("MyService3", { +class MyService3 extends Context.Service()("MyService3", { make: Effect.succeed({ value: 3 }) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_preview.ts b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_preview.ts index 7c42b373..f0b7a308 100644 --- a/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/multipleEffectProvide_preview.ts @@ -1,11 +1,11 @@ // @effect-diagnostics *:off // @effect-diagnostics multipleEffectProvide:warning -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class A extends ServiceMap.Service()("A", { make: Effect.succeed({}) }) { +class A extends Context.Service()("A", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class B extends ServiceMap.Service()("B", { make: Effect.succeed({}) }) { +class B extends Context.Service()("B", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } export const preview = Effect.void.pipe(Effect.provide(A.Default), Effect.provide(B.Default)) diff --git a/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass.ts b/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass.ts index 08a05cc9..a5341764 100644 --- a/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass.ts +++ b/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass.ts @@ -1,17 +1,17 @@ // @effect-diagnostics serviceNotAsClass:warning -import { ServiceMap } from "effect" +import { Context } from "effect" interface ConfigService {} -// Flagged: const variable with ServiceMap.Service -const Config = ServiceMap.Service("Config") +// Flagged: const variable with Context.Service +const Config = Context.Service("Config") -// Flagged: exported const variable with ServiceMap.Service +// Flagged: exported const variable with Context.Service interface ArtifactStoreService {} -export const ArtifactStore = ServiceMap.Service("@my-app/ArtifactStore") +export const ArtifactStore = Context.Service("@my-app/ArtifactStore") // Not flagged: correct class extends form -class MyService extends ServiceMap.Service()("MyService") {} +class MyService extends Context.Service()("MyService") {} -// Not flagged: non-ServiceMap.Service const +// Not flagged: non-Context.Service const const x = 42 diff --git a/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass_preview.ts b/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass_preview.ts index b98b51d0..89959227 100644 --- a/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/serviceNotAsClass_preview.ts @@ -1,5 +1,5 @@ // @effect-diagnostics *:off // @effect-diagnostics serviceNotAsClass:warning -import { ServiceMap } from "effect" +import { Context } from "effect" -export const Preview = ServiceMap.Service<{ port: number }>("Preview") +export const Preview = Context.Service<{ port: number }>("Preview") diff --git a/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide.ts b/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide.ts index 3f88ddd6..ce522876 100644 --- a/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide.ts +++ b/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide.ts @@ -1,13 +1,13 @@ // @effect-diagnostics strictEffectProvide:warning -import { ServiceMap, Effect, Layer } from "effect" +import { Context, Effect, Layer } from "effect" -class MyService1 extends ServiceMap.Service()("MyService1", { +class MyService1 extends Context.Service()("MyService1", { make: Effect.succeed({ value: 1 }) }) { static Default = Layer.effect(this, this.make) } -class MyService2 extends ServiceMap.Service()("MyService2", { +class MyService2 extends Context.Service()("MyService2", { make: Effect.succeed({ value: 2 }) }) { static Default = Layer.effect(this, this.make) @@ -46,6 +46,6 @@ export const shouldNotReport2 = Layer.provide( // Should NOT report: Effect.provide without layer arguments export const shouldNotReport3 = Effect.gen(function*() { - const ctx = yield* Effect.services() + const ctx = yield* Effect.context() return yield* Effect.provide(Effect.void, ctx) }) diff --git a/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide_preview.ts b/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide_preview.ts index d61349c9..13b6d51b 100644 --- a/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide_preview.ts +++ b/packages/harness-effect-v4/examples/diagnostics/strictEffectProvide_preview.ts @@ -1,8 +1,8 @@ // @effect-diagnostics *:off // @effect-diagnostics strictEffectProvide:warning -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class Config extends ServiceMap.Service()("Config", { make: Effect.succeed({}) }) { +class Config extends Context.Service()("Config", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } export const preview = Effect.void.pipe(Effect.provide(Config.Default)) diff --git a/packages/harness-effect-v4/examples/layer-graph/documented.ts b/packages/harness-effect-v4/examples/layer-graph/documented.ts index df451a1d..a11ed1dd 100644 --- a/packages/harness-effect-v4/examples/layer-graph/documented.ts +++ b/packages/harness-effect-v4/examples/layer-graph/documented.ts @@ -1,9 +1,9 @@ -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" /** * Manages database connections and pooling */ -export class DbConnection extends ServiceMap.Service()("DbConnection", { +export class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) @@ -12,7 +12,7 @@ export class DbConnection extends ServiceMap.Service()("DbConnecti /** * Provides file system access for reading and writing files */ -export class FileSystem extends ServiceMap.Service()("FileSystem", { +export class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) @@ -21,7 +21,7 @@ export class FileSystem extends ServiceMap.Service()("FileSystem", { /** * In-memory caching layer for improved performance */ -export class Cache extends ServiceMap.Service()("Cache", { +export class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) @@ -30,7 +30,7 @@ export class Cache extends ServiceMap.Service()("Cache", { /** * Repository for user data access and persistence */ -export class UserRepository extends ServiceMap.Service()("UserRepository", { +export class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/layer-graph/duplicated.ts b/packages/harness-effect-v4/examples/layer-graph/duplicated.ts index f5dc1c23..c63878ca 100644 --- a/packages/harness-effect-v4/examples/layer-graph/duplicated.ts +++ b/packages/harness-effect-v4/examples/layer-graph/duplicated.ts @@ -1,42 +1,42 @@ -import { Effect, Layer, ServiceMap, pipe } from "effect" +import { Effect, Layer, Context, pipe } from "effect" -class Database extends ServiceMap.Service()("Database", { +class Database extends Context.Service()("Database", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Database.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class EventsRepository extends ServiceMap.Service()("EventsRepository", { +class EventsRepository extends Context.Service()("EventsRepository", { make: Effect.as(Database.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class Analytics extends ServiceMap.Service()("Analytics", { +class Analytics extends Context.Service()("Analytics", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class UserService extends ServiceMap.Service()("UserService", { +class UserService extends Context.Service()("UserService", { make: Effect.as(Effect.andThen(UserRepository.asEffect(), Analytics.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) } -class EventService extends ServiceMap.Service()("EventService", { +class EventService extends Context.Service()("EventService", { make: Effect.as(Effect.andThen(EventsRepository.asEffect(), Analytics.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) } -class AppService extends ServiceMap.Service()("AppService", { +class AppService extends Context.Service()("AppService", { make: Effect.as(Effect.andThen(UserService.asEffect(), EventService.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/layer-graph/effect.ts b/packages/harness-effect-v4/examples/layer-graph/effect.ts index e23700c7..77fc83fa 100644 --- a/packages/harness-effect-v4/examples/layer-graph/effect.ts +++ b/packages/harness-effect-v4/examples/layer-graph/effect.ts @@ -1,6 +1,6 @@ -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DatabaseContext extends ServiceMap.Service()("DatabaseContext", { +class DatabaseContext extends Context.Service()("DatabaseContext", { make: Effect.succeed({ value: "DatabaseContext" as const }) diff --git a/packages/harness-effect-v4/examples/layer-graph/multiple.ts b/packages/harness-effect-v4/examples/layer-graph/multiple.ts index 6c8bbf63..399cba11 100644 --- a/packages/harness-effect-v4/examples/layer-graph/multiple.ts +++ b/packages/harness-effect-v4/examples/layer-graph/multiple.ts @@ -1,42 +1,42 @@ -import { Effect, Layer, ServiceMap, pipe } from "effect" +import { Effect, Layer, Context, pipe } from "effect" -class Database extends ServiceMap.Service()("Database", { +class Database extends Context.Service()("Database", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Database.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class EventsRepository extends ServiceMap.Service()("EventsRepository", { +class EventsRepository extends Context.Service()("EventsRepository", { make: Effect.as(Database.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class Analytics extends ServiceMap.Service()("Analytics", { +class Analytics extends Context.Service()("Analytics", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class UserService extends ServiceMap.Service()("UserService", { +class UserService extends Context.Service()("UserService", { make: Effect.as(Effect.andThen(UserRepository.asEffect(), Analytics.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) } -class EventService extends ServiceMap.Service()("EventService", { +class EventService extends Context.Service()("EventService", { make: Effect.as(Effect.andThen(EventsRepository.asEffect(), Analytics.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) } -class AppService extends ServiceMap.Service()("AppService", { +class AppService extends Context.Service()("AppService", { make: Effect.as(Effect.andThen(UserService.asEffect(), EventService.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/layer-graph/simple.ts b/packages/harness-effect-v4/examples/layer-graph/simple.ts index 8136d085..69197a82 100644 --- a/packages/harness-effect-v4/examples/layer-graph/simple.ts +++ b/packages/harness-effect-v4/examples/layer-graph/simple.ts @@ -1,21 +1,21 @@ -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -export class DbConnection extends ServiceMap.Service()("DbConnection", { +export class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -export class FileSystem extends ServiceMap.Service()("FileSystem", { +export class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -export class Cache extends ServiceMap.Service()("Cache", { +export class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -export class UserRepository extends ServiceMap.Service()("UserRepository", { +export class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/layer-graph/specialChars.ts b/packages/harness-effect-v4/examples/layer-graph/specialChars.ts index 28b72146..16ca2ddb 100644 --- a/packages/harness-effect-v4/examples/layer-graph/specialChars.ts +++ b/packages/harness-effect-v4/examples/layer-graph/specialChars.ts @@ -1,4 +1,4 @@ -import { Layer, ServiceMap } from "effect" +import { Layer, Context } from "effect" const MyTypeId: unique symbol = Symbol.for("x") type MyTypeId = typeof MyTypeId @@ -9,7 +9,7 @@ export interface IsGeneric { } -declare const WithSpecialChars: ServiceMap.ServiceChars#!">, { value: "WithSpecialChars" }> +declare const WithSpecialChars: Context.ServiceChars#!">, { value: "WithSpecialChars" }> const withSpecialCharsLayer = Layer.succeed(WithSpecialChars, { value: "WithSpecialChars" } as any) export const NoComment = withSpecialCharsLayer diff --git a/packages/harness-effect-v4/examples/refactors/layerMagic_build.ts b/packages/harness-effect-v4/examples/refactors/layerMagic_build.ts index d5848d38..dbcd984e 100644 --- a/packages/harness-effect-v4/examples/refactors/layerMagic_build.ts +++ b/packages/harness-effect-v4/examples/refactors/layerMagic_build.ts @@ -1,23 +1,23 @@ // 26:23,31:23,38:24,45:23,49:23,51:23 -import { Effect, Layer, ServiceMap } from "effect" +import { Effect, Layer, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) static bothInAndOut = Layer.effect(FileSystem, FileSystem.asEffect()) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/refactors/layerMagic_prepare.ts b/packages/harness-effect-v4/examples/refactors/layerMagic_prepare.ts index d042fdf7..9812a53a 100644 --- a/packages/harness-effect-v4/examples/refactors/layerMagic_prepare.ts +++ b/packages/harness-effect-v4/examples/refactors/layerMagic_prepare.ts @@ -1,22 +1,22 @@ // 25:20,27:20,32:20 -import { Effect, Layer, pipe, ServiceMap } from "effect" +import { Effect, Layer, pipe, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/refactors/layerMagic_prepareReuse.ts b/packages/harness-effect-v4/examples/refactors/layerMagic_prepareReuse.ts index 6c033bfb..7809441a 100644 --- a/packages/harness-effect-v4/examples/refactors/layerMagic_prepareReuse.ts +++ b/packages/harness-effect-v4/examples/refactors/layerMagic_prepareReuse.ts @@ -1,22 +1,22 @@ // 25:20,31:20 -import { Effect, Layer, pipe, ServiceMap } from "effect" +import { Effect, Layer, pipe, Context } from "effect" -class DbConnection extends ServiceMap.Service()("DbConnection", { +class DbConnection extends Context.Service()("DbConnection", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class FileSystem extends ServiceMap.Service()("FileSystem", { +class FileSystem extends Context.Service()("FileSystem", { make: Effect.succeed({}) }) { static Default = Layer.effect(this, this.make) } -class Cache extends ServiceMap.Service()("Cache", { +class Cache extends Context.Service()("Cache", { make: Effect.as(FileSystem.asEffect(), {}) }) { static Default = Layer.effect(this, this.make) } -class UserRepository extends ServiceMap.Service()("UserRepository", { +class UserRepository extends Context.Service()("UserRepository", { make: Effect.as(Effect.andThen(DbConnection.asEffect(), Cache.asEffect()), {}) }) { static Default = Layer.effect(this, this.make) diff --git a/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_simplify.ts b/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_simplify.ts index f0bf4f84..704ae962 100644 --- a/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_simplify.ts +++ b/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_simplify.ts @@ -6,7 +6,7 @@ export interface Service {} export const simple = Effect.succeed(true) export const simpleFailure = Effect.fail("Hello") -export const simpleRequire = Effect.services() +export const simpleRequire = Effect.context() export const inUnion = Math.random() > 0.1 ? Effect.succeed(true) : Effect.succeed(42) diff --git a/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_unnamed.ts b/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_unnamed.ts index 0220f895..1ab80e5d 100644 --- a/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_unnamed.ts +++ b/packages/harness-effect-v4/examples/refactors/toggleTypeAnnotation_unnamed.ts @@ -3,4 +3,4 @@ import * as Schema from "effect/Schema" export const debug = Schema.Struct({ id: Schema.Option(Schema.Number) -}).makeUnsafe +}).make diff --git a/packages/harness-effect-v4/examples/refactors/wrapWithEffectGen_noclass.ts b/packages/harness-effect-v4/examples/refactors/wrapWithEffectGen_noclass.ts index 116b8ae8..0cfcbcd2 100644 --- a/packages/harness-effect-v4/examples/refactors/wrapWithEffectGen_noclass.ts +++ b/packages/harness-effect-v4/examples/refactors/wrapWithEffectGen_noclass.ts @@ -1,6 +1,6 @@ // 4:36 -import { Effect, ServiceMap } from "effect" +import { Effect, Context } from "effect" -export class Asd extends ServiceMap.Service()("Asd", { +export class Asd extends Context.Service()("Asd", { make: Effect.succeed({}) }) {} diff --git a/packages/harness-effect-v4/package.json b/packages/harness-effect-v4/package.json index 2e9a7cf5..f6eaf0b1 100644 --- a/packages/harness-effect-v4/package.json +++ b/packages/harness-effect-v4/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@standard-schema/spec": "^1.1.0", - "effect": "^4.0.0-beta.43" + "effect": "^4.0.0-beta.46" }, "devDependencies": { "@types/node": "^25.0.6" diff --git a/packages/language-service/package.json b/packages/language-service/package.json index e17e8e28..b5d21a0b 100644 --- a/packages/language-service/package.json +++ b/packages/language-service/package.json @@ -43,10 +43,10 @@ "perf": "tsx test/perf.ts" }, "devDependencies": { - "@effect/platform-node": "^4.0.0-beta.43", + "@effect/platform-node": "^4.0.0-beta.46", "@types/pako": "^2.0.4", "@typescript-eslint/project-service": "^8.52.0", - "effect": "^4.0.0-beta.43", + "effect": "^4.0.0-beta.46", "pako": "^2.1.0", "ts-patch": "^3.3.0" } diff --git a/packages/language-service/src/cli/utils.ts b/packages/language-service/src/cli/utils.ts index 1fdde494..ea56a62d 100644 --- a/packages/language-service/src/cli/utils.ts +++ b/packages/language-service/src/cli/utils.ts @@ -1,3 +1,4 @@ +import * as Context from "effect/Context" import * as Data from "effect/Data" import * as Effect from "effect/Effect" import * as Encoding from "effect/Encoding" @@ -7,7 +8,6 @@ import * as Path from "effect/Path" import * as Predicate from "effect/Predicate" import * as Result from "effect/Result" import * as Schema from "effect/Schema" -import * as ServiceMap from "effect/ServiceMap" import type * as ts from "typescript" import * as TypeScriptUtils from "../core/TypeScriptUtils" @@ -65,7 +65,7 @@ export interface FileInput { /** * TypeScript API context for CLI operations */ -export class TypeScriptContext extends ServiceMap.Service()("TypeScriptContext") { +export class TypeScriptContext extends Context.Service()("TypeScriptContext") { static live = (cwd: string) => Layer.effect( TypeScriptContext, diff --git a/packages/language-service/src/completions/serviceMapSelfInClasses.ts b/packages/language-service/src/completions/serviceMapSelfInClasses.ts index 209af5fc..24597bf0 100644 --- a/packages/language-service/src/completions/serviceMapSelfInClasses.ts +++ b/packages/language-service/src/completions/serviceMapSelfInClasses.ts @@ -20,14 +20,14 @@ export const serviceMapSelfInClasses = LSP.createCompletion({ const { accessedObject, className, replacementSpan } = maybeInfos // first, given the position, we go back - const serviceMapIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel( + const contextIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel( sourceFile, "effect", - "ServiceMap" - ) || "ServiceMap" + "Context" + ) || "Context" // Check if this is a fully qualified name (e.g., Effect.Service) - const isFullyQualified = serviceMapIdentifier === ts.idText(accessedObject) + const isFullyQualified = contextIdentifier === ts.idText(accessedObject) const name = ts.idText(className) @@ -37,10 +37,10 @@ export const serviceMapSelfInClasses = LSP.createCompletion({ // Build completions based on what the user is extending const completions: Array = [] - // If extending ServiceMap.Service (either ServiceMap.Service or direct import ServiceMap.Service) + // If extending Context.Service (either Context.Service or direct import Context.Service) const hasServiceCompletion = isFullyQualified || Option.isSome( yield* pipe( - typeParser.isNodeReferenceToServiceMapModuleApi("Service")(accessedObject), + typeParser.isNodeReferenceToContextModuleApi("Service")(accessedObject), Nano.option ) ) @@ -49,7 +49,7 @@ export const serviceMapSelfInClasses = LSP.createCompletion({ name: `Service<${name}, {}>`, kind: ts.ScriptElementKind.constElement, insertText: isFullyQualified - ? `${serviceMapIdentifier}.Service<${name}, {${"${0}"}}>()("${tagKey}"){}` + ? `${contextIdentifier}.Service<${name}, {${"${0}"}}>()("${tagKey}"){}` : `Service<${name}, {${"${0}"}}>()("${tagKey}"){}`, replacementSpan, isSnippet: true @@ -58,7 +58,7 @@ export const serviceMapSelfInClasses = LSP.createCompletion({ name: `Service<${name}>({ make })`, kind: ts.ScriptElementKind.constElement, insertText: isFullyQualified - ? `${serviceMapIdentifier}.Service<${name}>()("${tagKey}", { make: ${"${0}"} }){}` + ? `${contextIdentifier}.Service<${name}>()("${tagKey}", { make: ${"${0}"} }){}` : `Service<${name}>()("${tagKey}", { make: ${"${0}"} }){}`, replacementSpan, isSnippet: true diff --git a/packages/language-service/src/core/TypeParser.ts b/packages/language-service/src/core/TypeParser.ts index c9e0cf13..b921f3ff 100644 --- a/packages/language-service/src/core/TypeParser.ts +++ b/packages/language-service/src/core/TypeParser.ts @@ -123,8 +123,8 @@ export interface TypeParser { isNodeReferenceToEffectLayerModuleApi: ( memberName: string ) => (node: ts.Node) => Nano.Nano - isServiceMapTypeSourceFile: (sourceFile: ts.SourceFile) => Nano.Nano - isNodeReferenceToServiceMapModuleApi: ( + isContextTypeSourceFile: (sourceFile: ts.SourceFile) => Nano.Nano + isNodeReferenceToContextModuleApi: ( memberName: string ) => (node: ts.Node) => Nano.Nano effectGen: ( @@ -242,7 +242,7 @@ export interface TypeParser { TypeParserIssue, never > - extendsServiceMapService: (atLocation: ts.ClassDeclaration) => Nano.Nano< + extendsContextService: (atLocation: ts.ClassDeclaration) => Nano.Nano< { className: ts.Identifier selfTypeNode: ts.TypeNode @@ -1781,8 +1781,8 @@ export function make( if (supportedEffect() !== "v4") return yield* typeParserIssue("v4 only") // should be pipeable yield* pipeableType(type, atLocation) - // Effect v4 beta.43 switched ServiceMap keys from nested variance markers - const typeIdSymbol = typeChecker.getPropertyOfType(type, "~effect/ServiceMap/Service") + // Effect v4 beta.43 switched Context keys from nested variance markers + const typeIdSymbol = typeChecker.getPropertyOfType(type, "~effect/Context/Service") if (!typeIdSymbol) { return yield* typeParserIssue("Type has no service key type id", type, atLocation) } @@ -2584,8 +2584,8 @@ export function make( (atLocation) => atLocation ) - const extendsServiceMapService = Nano.cachedBy( - Nano.fn("TypeParser.extendsServiceMapService")(function*( + const extendsContextService = Nano.cachedBy( + Nano.fn("TypeParser.extendsContextService")(function*( atLocation: ts.ClassDeclaration ) { if (!atLocation.name) { @@ -2600,18 +2600,18 @@ export function make( if (ts.isExpressionWithTypeArguments(typeX)) { const wholeCall = typeX.expression if (ts.isCallExpression(wholeCall)) { - const serviceMapServiceCall = wholeCall.expression + const contextServiceCall = wholeCall.expression if ( - ts.isCallExpression(serviceMapServiceCall) && - serviceMapServiceCall.typeArguments && serviceMapServiceCall.typeArguments.length > 0 + ts.isCallExpression(contextServiceCall) && + contextServiceCall.typeArguments && contextServiceCall.typeArguments.length > 0 ) { - const serviceMapServiceIdentifier = serviceMapServiceCall.expression - const selfTypeNode = serviceMapServiceCall.typeArguments[0]! - const isServiceMapService = yield* pipe( - isNodeReferenceToServiceMapModuleApi("Service")(serviceMapServiceIdentifier), + const contextServiceIdentifier = contextServiceCall.expression + const selfTypeNode = contextServiceCall.typeArguments[0]! + const isContextService = yield* pipe( + isNodeReferenceToContextModuleApi("Service")(contextServiceIdentifier), Nano.orUndefined ) - if (isServiceMapService) { + if (isContextService) { const classSym = typeChecker.getSymbolAtLocation(atLocation.name) if (!classSym) return yield* typeParserIssue("Class has no symbol", undefined, atLocation) const type = typeChecker.getTypeOfSymbol(classSym) @@ -2636,9 +2636,9 @@ export function make( } } - return yield* typeParserIssue("Class does not extend ServiceMap.Service", undefined, atLocation) + return yield* typeParserIssue("Class does not extend Context.Service", undefined, atLocation) }), - "TypeParser.extendsServiceMapService", + "TypeParser.extendsContextService", (atLocation) => atLocation ) @@ -2836,28 +2836,28 @@ export function make( (node) => node ) - const isServiceMapTypeSourceFile = Nano.cachedBy( - Nano.fn("TypeParser.isServiceMapTypeSourceFile")(function*( + const isContextTypeSourceFile = Nano.cachedBy( + Nano.fn("TypeParser.isContextTypeSourceFile")(function*( sourceFile: ts.SourceFile ) { const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile) if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", undefined, sourceFile) - const serviceMapSymbol = typeChecker.tryGetMemberInModuleExports("ServiceMap", moduleSymbol) - if (!serviceMapSymbol) return yield* typeParserIssue("ServiceMap not found", undefined, sourceFile) + const contextSymbol = typeChecker.tryGetMemberInModuleExports("Context", moduleSymbol) + if (!contextSymbol) return yield* typeParserIssue("Context not found", undefined, sourceFile) return sourceFile }), - "TypeParser.isServiceMapTypeSourceFile", + "TypeParser.isContextTypeSourceFile", (sourceFile) => sourceFile ) - const isNodeReferenceToServiceMapModuleApi = (memberName: string) => + const isNodeReferenceToContextModuleApi = (memberName: string) => Nano.cachedBy( - Nano.fn("TypeParser.isNodeReferenceToServiceMapModuleApi")(function*( + Nano.fn("TypeParser.isNodeReferenceToContextModuleApi")(function*( node: ts.Node ) { - return yield* isNodeReferenceToExportOfPackageModule(node, "effect", isServiceMapTypeSourceFile, memberName) + return yield* isNodeReferenceToExportOfPackageModule(node, "effect", isContextTypeSourceFile, memberName) }), - `TypeParser.isNodeReferenceToServiceMapModuleApi(${memberName})`, + `TypeParser.isNodeReferenceToContextModuleApi(${memberName})`, (node) => node ) @@ -3323,8 +3323,8 @@ export function make( isNodeReferenceToEffectSchemaModelModuleApi, isNodeReferenceToEffectLayerModuleApi, isNodeReferenceToEffectSchemaParserModuleApi, - isServiceMapTypeSourceFile, - isNodeReferenceToServiceMapModuleApi, + isContextTypeSourceFile, + isNodeReferenceToContextModuleApi, effectType, streamType, strictEffectType, @@ -3352,7 +3352,7 @@ export function make( promiseType, extendsEffectTag, extendsEffectService, - extendsServiceMapService, + extendsContextService, extendsContextTag, extendsSchemaClass, extendsSchemaTaggedClass, diff --git a/packages/language-service/src/diagnostics/classSelfMismatch.ts b/packages/language-service/src/diagnostics/classSelfMismatch.ts index e1754a11..d94b8b62 100644 --- a/packages/language-service/src/diagnostics/classSelfMismatch.ts +++ b/packages/language-service/src/diagnostics/classSelfMismatch.ts @@ -32,7 +32,7 @@ export const classSelfMismatch = LSP.createDiagnostic({ // Check if this class extends a class that has a Self type parameter const result = yield* pipe( typeParser.extendsEffectService(node), - Nano.orElse(() => typeParser.extendsServiceMapService(node)), + Nano.orElse(() => typeParser.extendsContextService(node)), Nano.orElse(() => typeParser.extendsContextTag(node)), Nano.orElse(() => typeParser.extendsEffectTag(node)), Nano.orElse(() => typeParser.extendsSchemaClass(node)), diff --git a/packages/language-service/src/diagnostics/deterministicKeys.ts b/packages/language-service/src/diagnostics/deterministicKeys.ts index f599b608..f32283e9 100644 --- a/packages/language-service/src/diagnostics/deterministicKeys.ts +++ b/packages/language-service/src/diagnostics/deterministicKeys.ts @@ -97,7 +97,7 @@ export const deterministicKeys = LSP.createDiagnostic({ typeParser.extendsEffectService(node), Nano.orElse(() => typeParser.extendsContextTag(node)), Nano.orElse(() => typeParser.extendsEffectTag(node)), - Nano.orElse(() => typeParser.extendsServiceMapService(node)), + Nano.orElse(() => typeParser.extendsContextService(node)), Nano.map(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "service" as const })) ), Nano.orElse(() => diff --git a/packages/language-service/src/diagnostics/effectFnOpportunity.ts b/packages/language-service/src/diagnostics/effectFnOpportunity.ts index 297a19f7..8690000b 100644 --- a/packages/language-service/src/diagnostics/effectFnOpportunity.ts +++ b/packages/language-service/src/diagnostics/effectFnOpportunity.ts @@ -258,9 +258,9 @@ export const effectFnOpportunity = LSP.createDiagnostic({ } ) - const tryMatchServiceMapMakeInference: ( + const tryMatchContextMakeInference: ( objectLiteral: ts.ObjectLiteralExpression - ) => Nano.Nano = Nano.fn("effectFnOpportunity.tryMatchServiceMapMakeInference")( + ) => Nano.Nano = Nano.fn("effectFnOpportunity.tryMatchContextMakeInference")( function*(objectLiteral: ts.ObjectLiteralExpression) { const returnStatement = objectLiteral.parent if (!returnStatement || !ts.isReturnStatement(returnStatement)) return undefined @@ -293,8 +293,8 @@ export const effectFnOpportunity = LSP.createDiagnostic({ } if (!classDeclaration || !classDeclaration.name) return undefined - const parsedServiceMapService = yield* Nano.option(typeParser.extendsServiceMapService(classDeclaration)) - if (parsedServiceMapService._tag === "None") return undefined + const parsedContextService = yield* Nano.orUndefined(typeParser.extendsContextService(classDeclaration)) + if (!parsedContextService) return undefined return ts.idText(classDeclaration.name) } @@ -334,8 +334,8 @@ export const effectFnOpportunity = LSP.createDiagnostic({ const ofServiceName = yield* tryMatchOfInference(objectLiteral) if (ofServiceName) return `${ofServiceName}.${suggestedTraceName}` - const serviceMapMakeServiceName = yield* tryMatchServiceMapMakeInference(objectLiteral) - return serviceMapMakeServiceName ? `${serviceMapMakeServiceName}.${suggestedTraceName}` : undefined + const contextMakeServiceName = yield* tryMatchContextMakeInference(objectLiteral) + return contextMakeServiceName ? `${contextMakeServiceName}.${suggestedTraceName}` : undefined } ) diff --git a/packages/language-service/src/diagnostics/outdatedApi.db.ts b/packages/language-service/src/diagnostics/outdatedApi.db.ts index 6c65bee6..b71b25bc 100644 --- a/packages/language-service/src/diagnostics/outdatedApi.db.ts +++ b/packages/language-service/src/diagnostics/outdatedApi.db.ts @@ -229,13 +229,13 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Fork the effect with Effect.forkChild and observe the fiber result via Fiber.join or Fiber.await." ), "Tag": asRemoved( - "Use ServiceMap.Service instead of Effect.Tag." + "Use Context.Service instead of Effect.Tag." ), "Service": asRemoved( - "Use ServiceMap.Service instead of Effect.Service." + "Use Context.Service instead of Effect.Service." ), "runtime": asRemoved( - "Runtime has been removed in Effect v4. Use Effect.services to grab services and then run using Effect.runPromiseWith." + "Runtime has been removed in Effect v4. Use Effect.context to grab services and then run using Effect.runPromiseWith." ), "bindAll": asRemoved( "Use Effect.gen instead of Effect.bindAll." @@ -292,12 +292,8 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "consoleWith": asRemoved( "Console access has been reworked in Effect v4." ), - "context": asRemoved( - "Use Effect.context is removed. Access services directly via yield* or Effect.provideService." - ), - "contextWith": asRemoved( - "Use Effect.map with service access instead." - ), + "context": asUnchanged, + "contextWith": asUnchanged, "contextWithEffect": asRemoved( "Use Effect.flatMap with service access instead." ), @@ -320,7 +316,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Use Effect.die with a lazily evaluated value instead." ), "diffFiberRefs": asRemoved( - "FiberRef has been replaced by ServiceMap.Reference in Effect v4." + "FiberRef has been replaced by Context.Reference in Effect v4." ), "disconnect": asRemoved( "Fiber disconnect has been removed in Effect v4." @@ -385,7 +381,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Use Effect.withSpan instead." ), "getFiberRefs": asRemoved( - "FiberRef has been replaced by ServiceMap.Reference in Effect v4." + "FiberRef has been replaced by Context.Reference in Effect v4." ), "getRuntimeFlags": asRemoved( "Runtime flags have been removed in Effect v4." @@ -400,7 +396,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Logging configuration has been reworked in Effect v4." ), "inheritFiberRefs": asRemoved( - "FiberRef has been replaced by ServiceMap.Reference in Effect v4." + "FiberRef has been replaced by Context.Reference in Effect v4." ), "interruptWith": asRemoved( "Use Effect.interrupt instead." @@ -424,16 +420,16 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Use Effect.linkSpans instead." ), "locally": asRemoved( - "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead." + "FiberRef.locally has been removed. Use Effect.provideService with Context.Reference instead." ), "locallyScoped": asRemoved( - "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead." + "FiberRef.locally has been removed. Use Effect.provideService with Context.Reference instead." ), "locallyScopedWith": asRemoved( - "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead." + "FiberRef.locally has been removed. Use Effect.provideService with Context.Reference instead." ), "locallyWith": asRemoved( - "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead." + "FiberRef.locally has been removed. Use Effect.provideService with Context.Reference instead." ), "logAnnotations": asRemoved( "Use Effect.annotateLogs instead." @@ -487,7 +483,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Finalizer ordering configuration has been removed in Effect v4." ), "patchFiberRefs": asRemoved( - "FiberRef has been replaced by ServiceMap.Reference in Effect v4." + "FiberRef has been replaced by Context.Reference in Effect v4." ), "patchRuntimeFlags": asRemoved( "Runtime flags have been removed in Effect v4." @@ -526,22 +522,22 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Finalizer ordering configuration has been removed in Effect v4." ), "serviceConstants": asRemoved( - "Service helpers have been removed. Use ServiceMap.Service and yield* to access services." + "Service helpers have been removed. Use Context.Service and yield* to access services." ), "serviceFunction": asRemoved( - "Service helpers have been removed. Use ServiceMap.Service and yield* to access services." + "Service helpers have been removed. Use Context.Service and yield* to access services." ), "serviceFunctionEffect": asRemoved( - "Service helpers have been removed. Use ServiceMap.Service and yield* to access services." + "Service helpers have been removed. Use Context.Service and yield* to access services." ), "serviceFunctions": asRemoved( - "Service helpers have been removed. Use ServiceMap.Service and yield* to access services." + "Service helpers have been removed. Use Context.Service and yield* to access services." ), "serviceMembers": asRemoved( - "Service helpers have been removed. Use ServiceMap.Service and yield* to access services." + "Service helpers have been removed. Use Context.Service and yield* to access services." ), "setFiberRefs": asRemoved( - "FiberRef has been replaced by ServiceMap.Reference in Effect v4." + "FiberRef has been replaced by Context.Reference in Effect v4." ), "step": asRemoved( "The request batching API has been reworked in Effect v4." @@ -613,7 +609,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Use Effect.catchCause instead." ), "updateFiberRefs": asRemoved( - "FiberRef has been replaced by ServiceMap.Reference in Effect v4." + "FiberRef has been replaced by Context.Reference in Effect v4." ), "using": asRemoved( "Use Effect.scoped instead." @@ -631,7 +627,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Use Effect.when with an effectful condition via Effect.flatMap instead." ), "whenFiberRef": asRemoved( - "FiberRef has been replaced by ServiceMap.Reference in Effect v4." + "FiberRef has been replaced by Context.Reference in Effect v4." ), "whenLogLevel": asRemoved( "Log level checking has been reworked in Effect v4." @@ -665,7 +661,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Note: in v4, only the Fiber is provided (not the full FiberRuntime with status). The callback receives (fiber: Fiber) instead of (fiber: FiberRuntime, status: FiberStatus)." ), "withMaxOpsBeforeYield": asRemoved( - "Use ServiceMap.Reference for MaxOpsBeforeYield configuration instead." + "Use Context.Reference for MaxOpsBeforeYield configuration instead." ), "withMetric": asRemoved( "Metric configuration has been reworked in Effect v4." @@ -695,7 +691,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Runtime flags have been removed in Effect v4." ), "withScheduler": asRemoved( - "Use ServiceMap.Reference for Scheduler configuration instead." + "Use Context.Reference for Scheduler configuration instead." ), "withSchedulingPriority": asRemoved( "Scheduling priority configuration has been removed in Effect v4." @@ -704,7 +700,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = { "Use Effect.withTracer instead." ), "withUnhandledErrorLogLevel": asRemoved( - "Use ServiceMap.Reference for UnhandledLogLevel configuration instead." + "Use Context.Reference for UnhandledLogLevel configuration instead." ), "zipLeft": asRemoved( "Use Effect.tap instead of Effect.zipLeft." diff --git a/packages/language-service/src/diagnostics/runEffectInsideEffect.ts b/packages/language-service/src/diagnostics/runEffectInsideEffect.ts index 5a20c4e9..27af466b 100644 --- a/packages/language-service/src/diagnostics/runEffectInsideEffect.ts +++ b/packages/language-service/src/diagnostics/runEffectInsideEffect.ts @@ -249,7 +249,7 @@ export const runEffectInsideEffect = LSP.createDiagnostic({ const v4MethodName = `${isEffectRunCall.value.methodName}With` const messageText = supportedEffect === "v4" - ? `\`${nodeText}\` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through \`Effect.services\` and \`Effect.${v4MethodName}\`.` + ? `\`${nodeText}\` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through \`Effect.context\` and \`Effect.${v4MethodName}\`.` : `\`${nodeText}\` is called inside an Effect with a separate runtime invocation. In this context, run child Effects with the surrounding runtime, which can be accessed through \`Effect.runtime\` and \`Runtime.${isEffectRunCall.value.methodName}\`.` report({ diff --git a/packages/language-service/src/diagnostics/serviceNotAsClass.ts b/packages/language-service/src/diagnostics/serviceNotAsClass.ts index 3c502824..bdcbfcce 100644 --- a/packages/language-service/src/diagnostics/serviceNotAsClass.ts +++ b/packages/language-service/src/diagnostics/serviceNotAsClass.ts @@ -8,7 +8,7 @@ import * as TypeScriptApi from "../core/TypeScriptApi.js" export const serviceNotAsClass = LSP.createDiagnostic({ name: "serviceNotAsClass", code: 51, - description: "Warns when ServiceMap.Service is used as a variable instead of a class declaration", + description: "Warns when Context.Service is used as a variable instead of a class declaration", group: "style", severity: "off", fixable: true, @@ -42,11 +42,11 @@ export const serviceNotAsClass = LSP.createDiagnostic({ if (!ts.isVariableDeclarationList(declList)) continue if (!(declList.flags & ts.NodeFlags.Const)) continue - const isServiceMapService = yield* pipe( - typeParser.isNodeReferenceToServiceMapModuleApi("Service")(callExpr.expression), + const isContextService = yield* pipe( + typeParser.isNodeReferenceToContextModuleApi("Service")(callExpr.expression), Nano.orUndefined ) - if (!isServiceMapService) continue + if (!isContextService) continue const variableName = ts.isIdentifier(node.name) ? ts.idText(node.name) @@ -65,7 +65,7 @@ export const serviceNotAsClass = LSP.createDiagnostic({ report({ location: callExpr, messageText: - `\`ServiceMap.Service\` is assigned to a variable here, but this API is intended for a class declaration shape such as \`class ${variableName} extends ServiceMap.Service<${variableName}, ${shapeText}>()("${ + `\`Context.Service\` is assigned to a variable here, but this API is intended for a class declaration shape such as \`class ${variableName} extends Context.Service<${variableName}, ${shapeText}>()("${ argsText.replace(/['"]/g, "") }") {}\`.`, fixes: [{ @@ -75,21 +75,21 @@ export const serviceNotAsClass = LSP.createDiagnostic({ const changeTracker = yield* Nano.service(TypeScriptApi.ChangeTracker) const targetNode = ts.isVariableStatement(variableStatement) ? variableStatement : declList - // Build inner call: ServiceMap.Service() + // Build inner call: Context.Service() const innerCall = ts.factory.createCallExpression( callExpr.expression, [ts.factory.createTypeReferenceNode(variableName), ...typeArgs], [] ) - // Build outer call: ServiceMap.Service()(args...) + // Build outer call: Context.Service()(args...) const outerCall = ts.factory.createCallExpression( innerCall, undefined, [...callExpr.arguments] ) - // Build heritage clause: extends ServiceMap.Service()(args...) + // Build heritage clause: extends Context.Service()(args...) const heritageClause = ts.factory.createHeritageClause( ts.SyntaxKind.ExtendsKeyword, [ts.factory.createExpressionWithTypeArguments(outerCall, undefined)] diff --git a/packages/language-service/src/metadata.json b/packages/language-service/src/metadata.json index f0cc6583..2b787b21 100644 --- a/packages/language-service/src/metadata.json +++ b/packages/language-service/src/metadata.json @@ -61,7 +61,7 @@ "v4" ], "preview": { - "sourceText": "import { Effect } from \"effect\"\n\nexport const preview = Effect.gen(function*() {\n yield* Effect.services()\n return yield* Effect.fail(\"boom\")\n})\n", + "sourceText": "import { Effect } from \"effect\"\n\nexport const preview = Effect.gen(function*() {\n yield* Effect.context()\n return yield* Effect.fail(\"boom\")\n})\n", "diagnostics": [ { "start": 46, @@ -70,12 +70,12 @@ }, { "start": 90, - "end": 116, + "end": 115, "text": "This has unknown in the requirements channel which is not recommended.\nOnly service identifiers should appear in the requirements channel. effect(anyUnknownInErrorContext)" }, { - "start": 133, - "end": 157, + "start": 132, + "end": 156, "text": "This has any in the error channel which is not recommended.\nHaving an unknown or any error type is not useful. Consider instead using specific error types baked by Data.TaggedError for example. effect(anyUnknownInErrorContext)" } ] @@ -191,11 +191,11 @@ "v4" ], "preview": { - "sourceText": "import { Effect, ServiceMap } from \"effect\"\n\nclass Db extends ServiceMap.Service()(\"Db\", { make: Effect.succeed({}) }) {}\n\n// @ts-expect-error\nexport const preview: Effect.Effect = Db.asEffect().pipe(Effect.asVoid)\n", + "sourceText": "import { Effect, Context } from \"effect\"\n\nclass Db extends Context.Service()(\"Db\", { make: Effect.succeed({}) }) {}\n\n// @ts-expect-error\nexport const preview: Effect.Effect = Db.asEffect().pipe(Effect.asVoid)\n", "diagnostics": [ { - "start": 160, - "end": 167, + "start": 154, + "end": 161, "text": "This Effect requires a service that is missing from the expected Effect context: `Db`. effect(missingEffectContext)" } ] @@ -233,11 +233,11 @@ "v4" ], "preview": { - "sourceText": "import { Effect, Layer, ServiceMap } from \"effect\"\n\nclass A extends ServiceMap.Service()(\"A\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\ndeclare const layer: Layer.Layer\n// @ts-expect-error\nexport const preview: Layer.Layer = layer\n", + "sourceText": "import { Effect, Layer, Context } from \"effect\"\n\nclass A extends Context.Service()(\"A\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\ndeclare const layer: Layer.Layer\n// @ts-expect-error\nexport const preview: Layer.Layer = layer\n", "diagnostics": [ { - "start": 259, - "end": 266, + "start": 253, + "end": 260, "text": "Missing 'A' in the expected Layer context. effect(missingLayerContext)" } ] @@ -561,11 +561,11 @@ "v4" ], "preview": { - "sourceText": "import { Effect, Layer, ServiceMap } from \"effect\"\n\nclass A extends ServiceMap.Service()(\"A\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nclass B extends ServiceMap.Service()(\"B\", { make: Effect.as(A.asEffect(), {}) }) {\n static Default = Layer.effect(this, this.make)\n}\nexport const preview = Layer.mergeAll(A.Default, B.Default)\n", + "sourceText": "import { Effect, Layer, Context } from \"effect\"\n\nclass A extends Context.Service()(\"A\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nclass B extends Context.Service()(\"B\", { make: Effect.as(A.asEffect(), {}) }) {\n static Default = Layer.effect(this, this.make)\n}\nexport const preview = Layer.mergeAll(A.Default, B.Default)\n", "diagnostics": [ { - "start": 355, - "end": 364, + "start": 346, + "end": 355, "text": "This layer provides A which is required by another layer in the same Layer.mergeAll call. Layer.mergeAll creates layers in parallel, so dependencies between layers will not be satisfied. Consider moving this layer into a Layer.provideMerge after the Layer.mergeAll. effect(layerMergeAllWithDependencies)" } ] @@ -603,11 +603,11 @@ "v4" ], "preview": { - "sourceText": "import type { Effect } from \"effect\"\nimport { ServiceMap } from \"effect\"\n\nclass FileSystem extends ServiceMap.Service Effect.Effect\n}>()(\"FileSystem\") {}\n\nexport class Cache extends ServiceMap.Service\n save: () => Effect.Effect\n}>()(\"Cache\") {}\n", + "sourceText": "import type { Effect } from \"effect\"\nimport { Context } from \"effect\"\n\nclass FileSystem extends Context.Service Effect.Effect\n}>()(\"FileSystem\") {}\n\nexport class Cache extends Context.Service\n save: () => Effect.Effect\n}>()(\"Cache\") {}\n", "diagnostics": [ { - "start": 212, - "end": 217, + "start": 206, + "end": 211, "text": "Methods of this Service require `FileSystem` from every caller.\n\nThe requirement becomes part of the public service surface instead of remaining internal to Layer implementation.\n\nResolve these dependencies at Layer creation and provide them to each method, so the service's type reflects its purpose, not its implementation.\n\nTo suppress this diagnostic for specific dependency types that are intentionally passed through (e.g., HttpServerRequest), add `@effect-leakable-service` JSDoc to their interface declarations (e.g., the `FileSystem` interface), or to this service by adding a `@effect-expect-leaking FileSystem` JSDoc.\n\nMore info and examples at https://effect.website/docs/requirements-management/layers/#avoiding-requirement-leakage effect(leakingRequirements)" } ] @@ -624,11 +624,11 @@ "v4" ], "preview": { - "sourceText": "import { Effect, Layer, ServiceMap } from \"effect\"\n\nclass A extends ServiceMap.Service()(\"A\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nclass B extends ServiceMap.Service()(\"B\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nexport const preview = Effect.void.pipe(Effect.provide(A.Default), Effect.provide(B.Default))\n", + "sourceText": "import { Effect, Layer, Context } from \"effect\"\n\nclass A extends Context.Service()(\"A\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nclass B extends Context.Service()(\"B\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nexport const preview = Effect.void.pipe(Effect.provide(A.Default), Effect.provide(B.Default))\n", "diagnostics": [ { - "start": 348, - "end": 373, + "start": 339, + "end": 364, "text": "This expression chains multiple `Effect.provide` calls. Providing Layers in multiple calls in a chain can break service lifecycle behavior compared with a single combined provide with merged layers. effect(multipleEffectProvide)" } ] @@ -671,7 +671,7 @@ { "start": 101, "end": 115, - "text": "`Effect.runSync` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through `Effect.services` and `Effect.runSyncWith`. effect(runEffectInsideEffect)" + "text": "`Effect.runSync` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through `Effect.context` and `Effect.runSyncWith`. effect(runEffectInsideEffect)" } ] } @@ -727,11 +727,11 @@ "v4" ], "preview": { - "sourceText": "import { Effect, Layer, ServiceMap } from \"effect\"\n\nclass Config extends ServiceMap.Service()(\"Config\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nexport const preview = Effect.void.pipe(Effect.provide(Config.Default))\n", + "sourceText": "import { Effect, Layer, Context } from \"effect\"\n\nclass Config extends Context.Service()(\"Config\", { make: Effect.succeed({}) }) {\n static Default = Layer.effect(this, this.make)\n}\nexport const preview = Effect.void.pipe(Effect.provide(Config.Default))\n", "diagnostics": [ { - "start": 235, - "end": 265, + "start": 229, + "end": 259, "text": "Effect.provide with a Layer should only be used at application entry points. If this is an entry point, you can safely disable this diagnostic. Otherwise, using Effect.provide may break scope lifetimes. Compose all layers at your entry point and provide them at once. effect(strictEffectProvide)" } ] @@ -1229,11 +1229,11 @@ "v4" ], "preview": { - "sourceText": "import { ServiceMap } from \"effect\"\n\nexport class RenamedService\n extends ServiceMap.Service()(\"CustomIdentifier\") {}\n", + "sourceText": "import { Context } from \"effect\"\n\nexport class RenamedService\n extends Context.Service()(\"CustomIdentifier\") {}\n", "diagnostics": [ { - "start": 116, - "end": 134, + "start": 110, + "end": 128, "text": "This key does not match the deterministic key for this declaration. The expected key is `@effect/harness-effect-v4/examples/diagnostics/deterministicKeys_preview/RenamedService`. effect(deterministicKeys)" } ] @@ -1492,19 +1492,19 @@ { "name": "serviceNotAsClass", "group": "style", - "description": "Warns when ServiceMap.Service is used as a variable instead of a class declaration", + "description": "Warns when Context.Service is used as a variable instead of a class declaration", "defaultSeverity": "off", "fixable": true, "supportedEffect": [ "v4" ], "preview": { - "sourceText": "import { ServiceMap } from \"effect\"\n\nexport const Preview = ServiceMap.Service<{ port: number }>(\"Preview\")\n", + "sourceText": "import { Context } from \"effect\"\n\nexport const Preview = Context.Service<{ port: number }>(\"Preview\")\n", "diagnostics": [ { - "start": 60, - "end": 107, - "text": "`ServiceMap.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class Preview extends ServiceMap.Service()(\"Preview\") {}`. effect(serviceNotAsClass)" + "start": 57, + "end": 101, + "text": "`Context.Service` is assigned to a variable here, but this API is intended for a class declaration shape such as `class Preview extends Context.Service()(\"Preview\") {}`. effect(serviceNotAsClass)" } ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c475071f..de2af518 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -124,8 +124,8 @@ importers: specifier: ^1.1.0 version: 1.1.0 effect: - specifier: ^4.0.0-beta.43 - version: 4.0.0-beta.43 + specifier: ^4.0.0-beta.46 + version: 4.0.0-beta.46 devDependencies: '@types/node': specifier: ^25.0.6 @@ -134,8 +134,8 @@ importers: packages/language-service: devDependencies: '@effect/platform-node': - specifier: ^4.0.0-beta.43 - version: 4.0.0-beta.43(effect@4.0.0-beta.43)(ioredis@5.10.0) + specifier: ^4.0.0-beta.46 + version: 4.0.0-beta.46(effect@4.0.0-beta.46)(ioredis@5.10.0) '@types/pako': specifier: ^2.0.4 version: 2.0.4 @@ -143,8 +143,8 @@ importers: specifier: ^8.52.0 version: 8.52.0(typescript@5.9.3) effect: - specifier: ^4.0.0-beta.43 - version: 4.0.0-beta.43 + specifier: ^4.0.0-beta.46 + version: 4.0.0-beta.46 pako: specifier: ^2.1.0 version: 2.1.0 @@ -575,29 +575,29 @@ packages: uuid: 11.1.0 dev: false - /@effect/platform-node-shared@4.0.0-beta.43(effect@4.0.0-beta.43): - resolution: {integrity: sha512-A9q0GEb61pYcQ06Dr6gXj1nKlDI3KHsar1sk3qb1ZY+kVSR64tBAylI8zGon23KY+NPtTUj/sEIToB7jc3Qt5w==} + /@effect/platform-node-shared@4.0.0-beta.46(effect@4.0.0-beta.46): + resolution: {integrity: sha512-Yzci82XbZ1W3tuiownsJawrJZTGeTrTZKLD0uxdBWCBzlVyqDwoSwRwO5qh33DurJj9B7iS8MDf14fpGRBPNGQ==} engines: {node: '>=18.0.0'} peerDependencies: - effect: ^4.0.0-beta.43 + effect: ^4.0.0-beta.46 dependencies: '@types/ws': 8.18.1 - effect: 4.0.0-beta.43 + effect: 4.0.0-beta.46 ws: 8.19.0 transitivePeerDependencies: - bufferutil - utf-8-validate dev: true - /@effect/platform-node@4.0.0-beta.43(effect@4.0.0-beta.43)(ioredis@5.10.0): - resolution: {integrity: sha512-Uq6E1rjaIpjHauzjwoB2HzAg3battYt2Boy8XO50GoHiWCXKE6WapYZ0/AnaBx5v5qg2sOfqpuiLsUf9ZgxOkA==} + /@effect/platform-node@4.0.0-beta.46(effect@4.0.0-beta.46)(ioredis@5.10.0): + resolution: {integrity: sha512-6AFRKjJO95dFl5lK/YnJi04uePjQDFi3+K1aXwcz/EfVlRwJ4+lg5O4vbievfKL/hnfcShVp3/eXnNS9tvlMZQ==} engines: {node: '>=18.0.0'} peerDependencies: - effect: ^4.0.0-beta.43 + effect: ^4.0.0-beta.46 ioredis: ^5.7.0 dependencies: - '@effect/platform-node-shared': 4.0.0-beta.43(effect@4.0.0-beta.43) - effect: 4.0.0-beta.43 + '@effect/platform-node-shared': 4.0.0-beta.46(effect@4.0.0-beta.46) + effect: 4.0.0-beta.46 ioredis: 5.10.0 mime: 4.1.0 undici: 7.24.5 @@ -2835,8 +2835,8 @@ packages: fast-check: 3.23.2 dev: false - /effect@4.0.0-beta.43: - resolution: {integrity: sha512-AJYyDimIwJOn87uUz/JzmgDc5GfjxJbXvEbTvNzMa+M3Uer344bLo/O5mMRkqc1vBleA+Ygs4+dbE3QsqOkKTQ==} + /effect@4.0.0-beta.46: + resolution: {integrity: sha512-3f6gXvvUMtEueCRY0tU76Vq2Pej1SAwwE+s0Owd5nD53yS5n4RZhUA1rlCGFuSbQFA225pGy8vO72+lpvu7u5A==} dependencies: '@standard-schema/spec': 1.1.0 fast-check: 4.5.3 diff --git a/schema.json b/schema.json index 9c7bdea8..4d9bab8b 100644 --- a/schema.json +++ b/schema.json @@ -2937,7 +2937,7 @@ "suggestion" ], "default": "off", - "description": "Warns when ServiceMap.Service is used as a variable instead of a class declaration Default severity: off." + "description": "Warns when Context.Service is used as a variable instead of a class declaration Default severity: off." }, "strictBooleanExpressions": { "type": "string",