Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { expect, layer } from "@effect/vitest"; |
| 2 | −import { Effect, Layer, Schema } from "effect"; | |
| 2 | +import { Effect, Layer, Predicate, Schema } from "effect"; | |
| 3 | 3 | import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi"; |
| 4 | 4 | import { HttpClient, HttpRouter, HttpServerRequest } from "effect/unstable/http"; |
| 5 | 5 | import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer"; |
| @@ -373,8 +373,10 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 367 unmodified lines | ||
| 373 | 373 | executor.tools.invoke("noauth.items.listItems", {}, autoApprove), |
| 374 | 374 | ); |
| 375 | 375 | |
| 376 | − expect((error as { _tag: string })._tag).toBe("ToolInvocationError"); | |
| 377 | − expect((error as { message: string }).message).toContain("missing-token"); | |
| 376 | + expect(Predicate.isTagged(error, "ToolInvocationError")).toBe(true); | |
| 377 | + expect(error).toMatchObject({ | |
| 378 | + message: expect.stringContaining("missing-token"), | |
| 379 | + }); | |
| 378 | 380 | }), |
| 379 | 381 | ); |
| 380 | 382 | |
| @@ -606,7 +608,7 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 225 unmodified lines | ||
| 606 | 608 | // Org-level base source |
| 607 | 609 | yield* executor.openapi.addSpec({ |
| 608 | 610 | spec: specJson, |
| 609 | − scope: ORG_SCOPE as string, | |
| 611 | + scope: String(ORG_SCOPE), | |
| 610 | 612 | namespace: "shared", |
| 611 | 613 | baseUrl: "", |
| 612 | 614 | name: "Org Source", |
| @@ -615,20 +617,20 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 2 unmodified lines | ||
| 615 | 617 | // Per-user shadow with the same namespace |
| 616 | 618 | yield* executor.openapi.addSpec({ |
| 617 | 619 | spec: specJson, |
| 618 | − scope: USER_SCOPE as string, | |
| 620 | + scope: String(USER_SCOPE), | |
| 619 | 621 | namespace: "shared", |
| 620 | 622 | name: "User Source", |
| 621 | 623 | }); |
| 622 | 624 | |
| 623 | − const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string); | |
| 624 | − const orgView = yield* executor.openapi.getSource("shared", ORG_SCOPE as string); | |
| 625 | + const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE)); | |
| 626 | + const orgView = yield* executor.openapi.getSource("shared", String(ORG_SCOPE)); | |
| 625 | 627 | |
| 626 | 628 | // Both rows must coexist — innermost-wins reads come from the |
| 627 | 629 | // executor; the store's scope-pinned getters return the exact row. |
| 628 | 630 | expect(userView?.name).toBe("User Source"); |
| 629 | − expect(userView?.scope).toBe(USER_SCOPE as string); | |
| 631 | + expect(userView?.scope).toBe(String(USER_SCOPE)); | |
| 630 | 632 | expect(orgView?.name).toBe("Org Source"); |
| 631 | − expect(orgView?.scope).toBe(ORG_SCOPE as string); | |
| 633 | + expect(orgView?.scope).toBe(String(ORG_SCOPE)); | |
| 632 | 634 | }), |
| 633 | 635 | ); |
| 634 | 636 | |
| @@ -652,20 +654,20 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 17 unmodified lines | ||
| 652 | 654 | |
| 653 | 655 | yield* executor.openapi.addSpec({ |
| 654 | 656 | spec: specJson, |
| 655 | − scope: ORG_SCOPE as string, | |
| 657 | + scope: String(ORG_SCOPE), | |
| 656 | 658 | namespace: "shared", |
| 657 | 659 | baseUrl: "https://org.example.com", |
| 658 | 660 | name: "Org Source", |
| 659 | 661 | }); |
| 660 | 662 | yield* executor.openapi.addSpec({ |
| 661 | 663 | spec: specJson, |
| 662 | − scope: USER_SCOPE as string, | |
| 664 | + scope: String(USER_SCOPE), | |
| 663 | 665 | namespace: "shared", |
| 664 | 666 | name: "User Source", |
| 665 | 667 | }); |
| 666 | 668 | |
| 667 | 669 | findManyCalls.length = 0; |
| 668 | − const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string); | |
| 670 | + const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE)); | |
| 669 | 671 | |
| 670 | 672 | expect(userView?.config.baseUrl).toBe("https://org.example.com"); |
| 671 | 673 | expect(findManyCalls.some((call) => call.model === "openapi_source")).toBe(false); |
| @@ -689,23 +691,23 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 17 unmodified lines | ||
| 689 | 691 | |
| 690 | 692 | yield* executor.openapi.addSpec({ |
| 691 | 693 | spec: specJson, |
| 692 | − scope: ORG_SCOPE as string, | |
| 694 | + scope: String(ORG_SCOPE), | |
| 693 | 695 | namespace: "shared", |
| 694 | 696 | baseUrl: "", |
| 695 | 697 | name: "Org Source", |
| 696 | 698 | }); |
| 697 | 699 | yield* executor.openapi.addSpec({ |
| 698 | 700 | spec: specJson, |
| 699 | − scope: USER_SCOPE as string, | |
| 701 | + scope: String(USER_SCOPE), | |
| 700 | 702 | namespace: "shared", |
| 701 | 703 | baseUrl: "", |
| 702 | 704 | name: "User Source", |
| 703 | 705 | }); |
| 704 | 706 | |
| 705 | − yield* executor.openapi.removeSpec("shared", USER_SCOPE as string); | |
| 707 | + yield* executor.openapi.removeSpec("shared", String(USER_SCOPE)); | |
| 706 | 708 | |
| 707 | − const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string); | |
| 708 | − const orgView = yield* executor.openapi.getSource("shared", ORG_SCOPE as string); | |
| 709 | + const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE)); | |
| 710 | + const orgView = yield* executor.openapi.getSource("shared", String(ORG_SCOPE)); | |
| 709 | 711 | |
| 710 | 712 | expect(userView).toBeNull(); |
| 711 | 713 | expect(orgView?.name).toBe("Org Source"); |
| @@ -729,26 +731,26 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 17 unmodified lines | ||
| 729 | 731 | |
| 730 | 732 | yield* executor.openapi.addSpec({ |
| 731 | 733 | spec: specJson, |
| 732 | − scope: ORG_SCOPE as string, | |
| 734 | + scope: String(ORG_SCOPE), | |
| 733 | 735 | namespace: "shared", |
| 734 | 736 | baseUrl: "https://org.example.com", |
| 735 | 737 | name: "Org Source", |
| 736 | 738 | }); |
| 737 | 739 | yield* executor.openapi.addSpec({ |
| 738 | 740 | spec: specJson, |
| 739 | − scope: USER_SCOPE as string, | |
| 741 | + scope: String(USER_SCOPE), | |
| 740 | 742 | namespace: "shared", |
| 741 | 743 | baseUrl: "https://user.example.com", |
| 742 | 744 | name: "User Source", |
| 743 | 745 | }); |
| 744 | 746 | |
| 745 | − yield* executor.openapi.updateSource("shared", USER_SCOPE as string, { | |
| 747 | + yield* executor.openapi.updateSource("shared", String(USER_SCOPE), { | |
| 746 | 748 | name: "User Renamed", |
| 747 | 749 | baseUrl: "https://user-new.example.com", |
| 748 | 750 | }); |
| 749 | 751 | |
| 750 | − const userView = yield* executor.openapi.getSource("shared", USER_SCOPE as string); | |
| 751 | − const orgView = yield* executor.openapi.getSource("shared", ORG_SCOPE as string); | |
| 752 | + const userView = yield* executor.openapi.getSource("shared", String(USER_SCOPE)); | |
| 753 | + const orgView = yield* executor.openapi.getSource("shared", String(ORG_SCOPE)); | |
| 752 | 754 | |
| 753 | 755 | expect(userView?.name).toBe("User Renamed"); |
| 754 | 756 | expect(userView?.config.baseUrl).toBe("https://user-new.example.com"); |
| @@ -939,7 +941,7 @@ layer(TestLayer)("OpenAPI Plugin", (it) => { · 184 unmodified lines | ||
| 939 | 941 | const failure = yield* executor.secrets |
| 940 | 942 | .remove(SecretId.make("locked")) |
| 941 | 943 | .pipe(Effect.flip); |
| 942 | − expect((failure as { _tag: string })._tag).toBe("SecretInUseError"); | |
| 944 | + expect(Predicate.isTagged(failure, "SecretInUseError")).toBe(true); | |
| 943 | 945 | |
| 944 | 946 | // Detach the binding, then remove succeeds. |
| 945 | 947 | yield* executor.openapi.removeSourceBinding( |