Unified · Split
| @@ -1,15 +1,25 @@ | ||
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | +import { | |
| 3 | + AccountIdSchema, | |
| 4 | + OrganizationIdSchema, | |
| 5 | + OrganizationMemberIdSchema, | |
| 6 | + WorkspaceIdSchema, | |
| 7 | +} from "#schema"; | |
| 2 | 8 | |
| 3 | 9 | import { deriveWorkspaceMembershipsForPrincipal } from "./workspace-membership"; |
| 4 | 10 | |
| 5 | 11 | describe("workspace membership derivation", () => { |
| 6 | 12 | it("prefers highest active role in matching organization", () => { |
| 13 | + const principalAccountId = AccountIdSchema.make("acc_1"); | |
| 14 | + const workspaceId = WorkspaceIdSchema.make("ws_1"); | |
| 15 | + const organizationId = OrganizationIdSchema.make("org_1"); | |
| 16 | + | |
| 7 | 17 | const memberships = deriveWorkspaceMembershipsForPrincipal({ |
| 8 | − principalAccountId: "acc_1" as never, | |
| 9 | − workspaceId: "ws_1" as never, | |
| 18 | + principalAccountId, | |
| 19 | + workspaceId, | |
| 10 | 20 | workspace: { |
| 11 | − id: "ws_1" as never, | |
| 12 | − organizationId: "org_1" as never, | |
| 21 | + id: workspaceId, | |
| 22 | + organizationId, | |
| 13 | 23 | name: "Main", |
| 14 | 24 | createdByAccountId: null, |
| 15 | 25 | createdAt: 1, |
| @@ -17,9 +27,9 @@ describe("workspace membership derivation", () => { · 1 unmodified line | ||
| 17 | 27 | }, |
| 18 | 28 | organizationMemberships: [ |
| 19 | 29 | { |
| 20 | − id: "mem_1" as never, | |
| 21 | − organizationId: "org_1" as never, | |
| 22 | − accountId: "acc_1" as never, | |
| 30 | + id: OrganizationMemberIdSchema.make("mem_1"), | |
| 31 | + organizationId, | |
| 32 | + accountId: principalAccountId, | |
| 23 | 33 | role: "viewer", |
| 24 | 34 | status: "active", |
| 25 | 35 | billable: true, |
| @@ -29,9 +39,9 @@ describe("workspace membership derivation", () => { · 3 unmodified lines | ||
| 29 | 39 | updatedAt: 1, |
| 30 | 40 | }, |
| 31 | 41 | { |
| 32 | − id: "mem_2" as never, | |
| 33 | − organizationId: "org_1" as never, | |
| 34 | − accountId: "acc_1" as never, | |
| 42 | + id: OrganizationMemberIdSchema.make("mem_2"), | |
| 43 | + organizationId, | |
| 44 | + accountId: principalAccountId, | |
| 35 | 45 | role: "admin", |
| 36 | 46 | status: "active", |
| 37 | 47 | billable: true, |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { HttpApiBuilder, HttpServerRequest } from "@effect/platform"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | +import type { WorkspaceId } from "#schema"; | |
| 3 | 4 | |
| 4 | 5 | import { |
| 5 | 6 | Actor, |
| @@ -37,21 +38,18 @@ const toUnauthorizedError = ( · 31 unmodified lines | ||
| 37 | 38 | details: "Authentication required", |
| 38 | 39 | }); |
| 39 | 40 | |
| 40 | −const resolveWorkspaceActor = (workspaceId: string) => | |
| 41 | +const resolveWorkspaceActor = (workspaceId: WorkspaceId) => | |
| 41 | 42 | Effect.gen(function* () { |
| 42 | 43 | const actorResolver = yield* ControlPlaneActorResolver; |
| 43 | 44 | const request = yield* HttpServerRequest.HttpServerRequest; |
| 44 | 45 | |
| 45 | − return yield* actorResolver.resolveWorkspaceActor({ | |
| 46 | − workspaceId: workspaceId as never, | |
| 47 | − headers: request.headers, | |
| 48 | − }); | |
| 46 | + return yield* actorResolver.resolveWorkspaceActor({ workspaceId, headers: request.headers }); | |
| 49 | 47 | }); |
| 50 | 48 | |
| 51 | −const requireExecuteWorkspace = (workspaceId: string) => | |
| 49 | +const requireExecuteWorkspace = (workspaceId: WorkspaceId) => | |
| 52 | 50 | requirePermission({ |
| 53 | 51 | permission: "workspace:read", |
| 54 | − workspaceId: workspaceId as never, | |
| 52 | + workspaceId, | |
| 55 | 53 | }); |
| 56 | 54 | |
| 57 | 55 | export const ControlPlaneExecutionsLive = HttpApiBuilder.group( |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { HttpApiBuilder, HttpServerRequest } from "@effect/platform"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | +import type { OrganizationId } from "#schema"; | |
| 3 | 4 | |
| 4 | 5 | import { |
| 5 | 6 | Actor, |
| @@ -43,16 +44,16 @@ const resolveActor = Effect.gen(function* () { · 37 unmodified lines | ||
| 43 | 44 | return yield* actorResolver.resolveActor({ headers: request.headers }); |
| 44 | 45 | }); |
| 45 | 46 | |
| 46 | −const requireReadMemberships = (organizationId: string) => | |
| 47 | +const requireReadMemberships = (organizationId: OrganizationId) => | |
| 47 | 48 | requirePermission({ |
| 48 | 49 | permission: "memberships:read", |
| 49 | − organizationId: organizationId as never, | |
| 50 | + organizationId, | |
| 50 | 51 | }); |
| 51 | 52 | |
| 52 | −const requireWriteMemberships = (organizationId: string) => | |
| 53 | +const requireWriteMemberships = (organizationId: OrganizationId) => | |
| 53 | 54 | requirePermission({ |
| 54 | 55 | permission: "memberships:write", |
| 55 | − organizationId: organizationId as never, | |
| 56 | + organizationId, | |
| 56 | 57 | }); |
| 57 | 58 | |
| 58 | 59 | export const ControlPlaneMembershipsLive = HttpApiBuilder.group( |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { HttpApiBuilder, HttpServerRequest } from "@effect/platform"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | +import type { OrganizationId } from "#schema"; | |
| 3 | 4 | |
| 4 | 5 | import { |
| 5 | 6 | Actor, |
| @@ -47,10 +48,10 @@ const requireReadOrganizations = requirePermission({ · 41 unmodified lines | ||
| 47 | 48 | permission: "organizations:read", |
| 48 | 49 | }); |
| 49 | 50 | |
| 50 | −const requireManageOrganizations = (organizationId: string) => | |
| 51 | +const requireManageOrganizations = (organizationId: OrganizationId) => | |
| 51 | 52 | requirePermission({ |
| 52 | 53 | permission: "organizations:manage", |
| 53 | − organizationId: organizationId as never, | |
| 54 | + organizationId, | |
| 54 | 55 | }); |
| 55 | 56 | |
| 56 | 57 | export const ControlPlaneOrganizationsLive = HttpApiBuilder.group( |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { HttpApiBuilder, HttpServerRequest } from "@effect/platform"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | +import type { WorkspaceId } from "#schema"; | |
| 3 | 4 | |
| 4 | 5 | import { |
| 5 | 6 | Actor, |
| @@ -37,27 +38,24 @@ const toUnauthorizedError = ( · 31 unmodified lines | ||
| 37 | 38 | details: "Authentication required", |
| 38 | 39 | }); |
| 39 | 40 | |
| 40 | −const resolveWorkspaceActor = (workspaceId: string) => | |
| 41 | +const resolveWorkspaceActor = (workspaceId: WorkspaceId) => | |
| 41 | 42 | Effect.gen(function* () { |
| 42 | 43 | const actorResolver = yield* ControlPlaneActorResolver; |
| 43 | 44 | const request = yield* HttpServerRequest.HttpServerRequest; |
| 44 | 45 | |
| 45 | − return yield* actorResolver.resolveWorkspaceActor({ | |
| 46 | − workspaceId: workspaceId as never, | |
| 47 | − headers: request.headers, | |
| 48 | − }); | |
| 46 | + return yield* actorResolver.resolveWorkspaceActor({ workspaceId, headers: request.headers }); | |
| 49 | 47 | }); |
| 50 | 48 | |
| 51 | −const requireReadPolicies = (workspaceId: string) => | |
| 49 | +const requireReadPolicies = (workspaceId: WorkspaceId) => | |
| 52 | 50 | requirePermission({ |
| 53 | 51 | permission: "policies:read", |
| 54 | − workspaceId: workspaceId as never, | |
| 52 | + workspaceId, | |
| 55 | 53 | }); |
| 56 | 54 | |
| 57 | −const requireWritePolicies = (workspaceId: string) => | |
| 55 | +const requireWritePolicies = (workspaceId: WorkspaceId) => | |
| 58 | 56 | requirePermission({ |
| 59 | 57 | permission: "policies:write", |
| 60 | − workspaceId: workspaceId as never, | |
| 58 | + workspaceId, | |
| 61 | 59 | }); |
| 62 | 60 | |
| 63 | 61 | export const ControlPlanePoliciesLive = HttpApiBuilder.group( |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { HttpApiBuilder, HttpServerRequest } from "@effect/platform"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | +import type { WorkspaceId } from "#schema"; | |
| 3 | 4 | |
| 4 | 5 | import { |
| 5 | 6 | Actor, |
| @@ -37,27 +38,24 @@ const toUnauthorizedError = ( · 31 unmodified lines | ||
| 37 | 38 | details: "Authentication required", |
| 38 | 39 | }); |
| 39 | 40 | |
| 40 | −const resolveWorkspaceActor = (workspaceId: string) => | |
| 41 | +const resolveWorkspaceActor = (workspaceId: WorkspaceId) => | |
| 41 | 42 | Effect.gen(function* () { |
| 42 | 43 | const actorResolver = yield* ControlPlaneActorResolver; |
| 43 | 44 | const request = yield* HttpServerRequest.HttpServerRequest; |
| 44 | 45 | |
| 45 | − return yield* actorResolver.resolveWorkspaceActor({ | |
| 46 | − workspaceId: workspaceId as never, | |
| 47 | − headers: request.headers, | |
| 48 | − }); | |
| 46 | + return yield* actorResolver.resolveWorkspaceActor({ workspaceId, headers: request.headers }); | |
| 49 | 47 | }); |
| 50 | 48 | |
| 51 | −const requireReadSources = (workspaceId: string) => | |
| 49 | +const requireReadSources = (workspaceId: WorkspaceId) => | |
| 52 | 50 | requirePermission({ |
| 53 | 51 | permission: "sources:read", |
| 54 | − workspaceId: workspaceId as never, | |
| 52 | + workspaceId, | |
| 55 | 53 | }); |
| 56 | 54 | |
| 57 | −const requireWriteSources = (workspaceId: string) => | |
| 55 | +const requireWriteSources = (workspaceId: WorkspaceId) => | |
| 58 | 56 | requirePermission({ |
| 59 | 57 | permission: "sources:write", |
| 60 | − workspaceId: workspaceId as never, | |
| 58 | + workspaceId, | |
| 61 | 59 | }); |
| 62 | 60 | |
| 63 | 61 | export const ControlPlaneSourcesLive = HttpApiBuilder.group( |
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { HttpApiBuilder, HttpServerRequest } from "@effect/platform"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | +import type { OrganizationId, WorkspaceId } from "#schema"; | |
| 3 | 4 | |
| 4 | 5 | import { |
| 5 | 6 | Actor, |
| @@ -43,39 +44,36 @@ const resolveActor = Effect.gen(function* () { · 37 unmodified lines | ||
| 43 | 44 | return yield* actorResolver.resolveActor({ headers: request.headers }); |
| 44 | 45 | }); |
| 45 | 46 | |
| 46 | −const resolveWorkspaceActor = (workspaceId: string) => | |
| 47 | +const resolveWorkspaceActor = (workspaceId: WorkspaceId) => | |
| 47 | 48 | Effect.gen(function* () { |
| 48 | 49 | const actorResolver = yield* ControlPlaneActorResolver; |
| 49 | 50 | const request = yield* HttpServerRequest.HttpServerRequest; |
| 50 | 51 | |
| 51 | − return yield* actorResolver.resolveWorkspaceActor({ | |
| 52 | − workspaceId: workspaceId as never, | |
| 53 | − headers: request.headers, | |
| 54 | − }); | |
| 52 | + return yield* actorResolver.resolveWorkspaceActor({ workspaceId, headers: request.headers }); | |
| 55 | 53 | }); |
| 56 | 54 | |
| 57 | −const requireReadWorkspace = (workspaceId: string) => | |
| 55 | +const requireReadWorkspace = (workspaceId: WorkspaceId) => | |
| 58 | 56 | requirePermission({ |
| 59 | 57 | permission: "workspace:read", |
| 60 | − workspaceId: workspaceId as never, | |
| 58 | + workspaceId, | |
| 61 | 59 | }); |
| 62 | 60 | |
| 63 | −const requireManageWorkspace = (workspaceId: string) => | |
| 61 | +const requireManageWorkspace = (workspaceId: WorkspaceId) => | |
| 64 | 62 | requirePermission({ |
| 65 | 63 | permission: "workspace:manage", |
| 66 | − workspaceId: workspaceId as never, | |
| 64 | + workspaceId, | |
| 67 | 65 | }); |
| 68 | 66 | |
| 69 | −const requireOrganizationWorkspaceRead = (organizationId: string) => | |
| 67 | +const requireOrganizationWorkspaceRead = (organizationId: OrganizationId) => | |
| 70 | 68 | requirePermission({ |
| 71 | 69 | permission: "workspace:read", |
| 72 | − organizationId: organizationId as never, | |
| 70 | + organizationId, | |
| 73 | 71 | }); |
| 74 | 72 | |
| 75 | −const requireOrganizationWorkspaceManage = (organizationId: string) => | |
| 73 | +const requireOrganizationWorkspaceManage = (organizationId: OrganizationId) => | |
| 76 | 74 | requirePermission({ |
| 77 | 75 | permission: "workspace:manage", |
| 78 | − organizationId: organizationId as never, | |
| 76 | + organizationId, | |
| 79 | 77 | }); |
| 80 | 78 | |
| 81 | 79 | export const ControlPlaneWorkspacesLive = HttpApiBuilder.group( |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | +import { AccountIdSchema, WorkspaceIdSchema } from "#schema"; | |
| 2 | 3 | import * as Effect from "effect/Effect"; |
| 3 | 4 | |
| 4 | 5 | import { |
| @@ -10,9 +11,12 @@ import { · 5 unmodified lines | ||
| 10 | 11 | describe("control-plane-domain actor", () => { |
| 11 | 12 | it.effect("allows workspace permissions from active membership", () => |
| 12 | 13 | Effect.gen(function* () { |
| 14 | + const accountId = AccountIdSchema.make("acc_1"); | |
| 15 | + const workspaceId = WorkspaceIdSchema.make("ws_1"); | |
| 16 | + | |
| 13 | 17 | const actor = yield* makeActor({ |
| 14 | 18 | principal: { |
| 15 | − accountId: "acc_1" as never, | |
| 19 | + accountId, | |
| 16 | 20 | provider: "local", |
| 17 | 21 | subject: "local:acc_1", |
| 18 | 22 | email: null, |
| @@ -20,8 +24,8 @@ describe("control-plane-domain actor", () => { · 1 unmodified line | ||
| 20 | 24 | }, |
| 21 | 25 | workspaceMemberships: [ |
| 22 | 26 | { |
| 23 | − accountId: "acc_1" as never, | |
| 24 | − workspaceId: "ws_1" as never, | |
| 27 | + accountId, | |
| 28 | + workspaceId, | |
| 25 | 29 | role: "editor", |
| 26 | 30 | status: "active", |
| 27 | 31 | grantedAt: 1, |
| @@ -33,16 +37,19 @@ describe("control-plane-domain actor", () => { · 5 unmodified lines | ||
| 33 | 37 | |
| 34 | 38 | yield* actor.requirePermission({ |
| 35 | 39 | permission: "sources:write", |
| 36 | − workspaceId: "ws_1" as never, | |
| 40 | + workspaceId, | |
| 37 | 41 | }); |
| 38 | 42 | }), |
| 39 | 43 | ); |
| 40 | 44 | |
| 41 | 45 | it.effect("denies permission when role is insufficient", () => |
| 42 | 46 | Effect.gen(function* () { |
| 47 | + const accountId = AccountIdSchema.make("acc_1"); | |
| 48 | + const workspaceId = WorkspaceIdSchema.make("ws_1"); | |
| 49 | + | |
| 43 | 50 | const actor = yield* makeActor({ |
| 44 | 51 | principal: { |
| 45 | − accountId: "acc_1" as never, | |
| 52 | + accountId, | |
| 46 | 53 | provider: "local", |
| 47 | 54 | subject: "local:acc_1", |
| 48 | 55 | email: null, |
| @@ -50,8 +57,8 @@ describe("control-plane-domain actor", () => { · 1 unmodified line | ||
| 50 | 57 | }, |
| 51 | 58 | workspaceMemberships: [ |
| 52 | 59 | { |
| 53 | − accountId: "acc_1" as never, | |
| 54 | − workspaceId: "ws_1" as never, | |
| 60 | + accountId, | |
| 61 | + workspaceId, | |
| 55 | 62 | role: "viewer", |
| 56 | 63 | status: "active", |
| 57 | 64 | grantedAt: 1, |
| @@ -64,7 +71,7 @@ describe("control-plane-domain actor", () => { · 6 unmodified lines | ||
| 64 | 71 | const denied = yield* Effect.either( |
| 65 | 72 | actor.requirePermission({ |
| 66 | 73 | permission: "sources:write", |
| 67 | − workspaceId: "ws_1" as never, | |
| 74 | + workspaceId, | |
| 68 | 75 | }), |
| 69 | 76 | ); |
| 70 | 77 | |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | +import { AccountIdSchema, WorkspaceIdSchema } from "#schema"; | |
| 2 | 3 | import * as Effect from "effect/Effect"; |
| 3 | 4 | |
| 4 | 5 | import { Actor, makeAllowAllActor } from "./actor"; |
| @@ -7,8 +8,11 @@ import { requirePermission, withPolicy } from "./policy"; · 2 unmodified lines | ||
| 7 | 8 | describe("control-plane-domain policy", () => { |
| 8 | 9 | it.effect("runs protected effect when permission is granted", () => |
| 9 | 10 | Effect.gen(function* () { |
| 11 | + const accountId = AccountIdSchema.make("acc_1"); | |
| 12 | + const workspaceId = WorkspaceIdSchema.make("ws_1"); | |
| 13 | + | |
| 10 | 14 | const principal = { |
| 11 | − accountId: "acc_1" as never, | |
| 15 | + accountId, | |
| 12 | 16 | provider: "local" as const, |
| 13 | 17 | subject: "local:acc_1", |
| 14 | 18 | email: null, |
| @@ -18,7 +22,7 @@ describe("control-plane-domain policy", () => { · 3 unmodified lines | ||
| 18 | 22 | const result = yield* withPolicy( |
| 19 | 23 | requirePermission({ |
| 20 | 24 | permission: "workspace:read", |
| 21 | − workspaceId: "ws_1" as never, | |
| 25 | + workspaceId, | |
| 22 | 26 | }), |
| 23 | 27 | )(Effect.succeed("ok")).pipe( |
| 24 | 28 | Effect.provideService(Actor, makeAllowAllActor(principal)), |
| @@ -1,4 +1,12 @@ | ||
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | +import { | |
| 3 | + AccountIdSchema, | |
| 4 | + OrganizationIdSchema, | |
| 5 | + OrganizationMemberIdSchema, | |
| 6 | + PolicyIdSchema, | |
| 7 | + SourceIdSchema, | |
| 8 | + WorkspaceIdSchema, | |
| 9 | +} from "#schema"; | |
| 2 | 10 | import * as Effect from "effect/Effect"; |
| 3 | 11 | import * as Option from "effect/Option"; |
| 4 | 12 | |
| @@ -20,29 +28,32 @@ describe("control-plane-persistence-drizzle", () => { · 15 unmodified lines | ||
| 20 | 28 | Effect.gen(function* () { |
| 21 | 29 | const persistence = yield* makePersistence; |
| 22 | 30 | const now = Date.now(); |
| 31 | + const organizationId = OrganizationIdSchema.make("org_1"); | |
| 32 | + const accountId = AccountIdSchema.make("acc_1"); | |
| 33 | + const workspaceId = WorkspaceIdSchema.make("ws_1"); | |
| 23 | 34 | |
| 24 | 35 | yield* persistence.rows.organizations.insert({ |
| 25 | − id: "org_1" as never, | |
| 36 | + id: organizationId, | |
| 26 | 37 | slug: "acme", |
| 27 | 38 | name: "Acme", |
| 28 | 39 | status: "active", |
| 29 | − createdByAccountId: "acc_1" as never, | |
| 40 | + createdByAccountId: accountId, | |
| 30 | 41 | createdAt: now, |
| 31 | 42 | updatedAt: now, |
| 32 | 43 | }); |
| 33 | 44 | |
| 34 | 45 | yield* persistence.rows.workspaces.insert({ |
| 35 | − id: "ws_1" as never, | |
| 36 | − organizationId: "org_1" as never, | |
| 46 | + id: workspaceId, | |
| 47 | + organizationId, | |
| 37 | 48 | name: "Main", |
| 38 | − createdByAccountId: "acc_1" as never, | |
| 49 | + createdByAccountId: accountId, | |
| 39 | 50 | createdAt: now, |
| 40 | 51 | updatedAt: now, |
| 41 | 52 | }); |
| 42 | 53 | |
| 43 | 54 | yield* persistence.rows.sources.insert({ |
| 44 | − id: "src_1" as never, | |
| 45 | − workspaceId: "ws_1" as never, | |
| 55 | + id: SourceIdSchema.make("src_1"), | |
| 56 | + workspaceId, | |
| 46 | 57 | name: "Github", |
| 47 | 58 | kind: "openapi", |
| 48 | 59 | endpoint: "https://api.github.com/openapi.json", |
| @@ -56,8 +67,8 @@ describe("control-plane-persistence-drizzle", () => { · 7 unmodified lines | ||
| 56 | 67 | }); |
| 57 | 68 | |
| 58 | 69 | yield* persistence.rows.policies.insert({ |
| 59 | − id: "pol_1" as never, | |
| 60 | − workspaceId: "ws_1" as never, | |
| 70 | + id: PolicyIdSchema.make("pol_1"), | |
| 71 | + workspaceId, | |
| 61 | 72 | targetAccountId: null, |
| 62 | 73 | clientId: null, |
| 63 | 74 | resourceType: "tool_path", |
| @@ -72,14 +83,14 @@ describe("control-plane-persistence-drizzle", () => { · 8 unmodified lines | ||
| 72 | 83 | updatedAt: now, |
| 73 | 84 | }); |
| 74 | 85 | |
| 75 | − const workspace = yield* persistence.rows.workspaces.getById("ws_1" as never); | |
| 86 | + const workspace = yield* persistence.rows.workspaces.getById(workspaceId); | |
| 76 | 87 | expect(Option.isSome(workspace)).toBe(true); |
| 77 | 88 | |
| 78 | − const sources = yield* persistence.rows.sources.listByWorkspaceId("ws_1" as never); | |
| 89 | + const sources = yield* persistence.rows.sources.listByWorkspaceId(workspaceId); | |
| 79 | 90 | expect(sources).toHaveLength(1); |
| 80 | 91 | expect(sources[0]?.name).toBe("Github"); |
| 81 | 92 | |
| 82 | − const policies = yield* persistence.rows.policies.listByWorkspaceId("ws_1" as never); | |
| 93 | + const policies = yield* persistence.rows.policies.listByWorkspaceId(workspaceId); | |
| 83 | 94 | expect(policies).toHaveLength(1); |
| 84 | 95 | expect(policies[0]?.resourcePattern).toBe("source.github.*"); |
| 85 | 96 | }), |
| @@ -89,11 +100,13 @@ describe("control-plane-persistence-drizzle", () => { · 3 unmodified lines | ||
| 89 | 100 | Effect.gen(function* () { |
| 90 | 101 | const persistence = yield* makePersistence; |
| 91 | 102 | const now = Date.now(); |
| 103 | + const organizationId = OrganizationIdSchema.make("org_1"); | |
| 104 | + const accountId = AccountIdSchema.make("acc_1"); | |
| 92 | 105 | |
| 93 | 106 | yield* persistence.rows.organizationMemberships.upsert({ |
| 94 | − id: "mem_1" as never, | |
| 95 | − organizationId: "org_1" as never, | |
| 96 | − accountId: "acc_1" as never, | |
| 107 | + id: OrganizationMemberIdSchema.make("mem_1"), | |
| 108 | + organizationId, | |
| 109 | + accountId, | |
| 97 | 110 | role: "viewer", |
| 98 | 111 | status: "active", |
| 99 | 112 | billable: true, |
| @@ -104,9 +117,9 @@ describe("control-plane-persistence-drizzle", () => { · 4 unmodified lines | ||
| 104 | 117 | }); |
| 105 | 118 | |
| 106 | 119 | yield* persistence.rows.organizationMemberships.upsert({ |
| 107 | − id: "mem_2" as never, | |
| 108 | − organizationId: "org_1" as never, | |
| 109 | − accountId: "acc_1" as never, | |
| 120 | + id: OrganizationMemberIdSchema.make("mem_2"), | |
| 121 | + organizationId, | |
| 122 | + accountId, | |
| 110 | 123 | role: "admin", |
| 111 | 124 | status: "active", |
| 112 | 125 | billable: true, |
| @@ -117,8 +130,8 @@ describe("control-plane-persistence-drizzle", () => { · 4 unmodified lines | ||
| 117 | 130 | }); |
| 118 | 131 | |
| 119 | 132 | const membership = yield* persistence.rows.organizationMemberships.getByOrganizationAndAccount( |
| 120 | − "org_1" as never, | |
| 121 | − "acc_1" as never, | |
| 133 | + organizationId, | |
| 134 | + accountId, | |
| 122 | 135 | ); |
| 123 | 136 | |
| 124 | 137 | expect(Option.isSome(membership)).toBe(true); |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | 2 | import * as Effect from "effect/Effect"; |
| 3 | 3 | |
| 4 | −import type { AccountId } from "#schema"; | |
| 4 | +import { WorkspaceIdSchema, type AccountId } from "#schema"; | |
| 5 | 5 | |
| 6 | 6 | import { makeSqlControlPlaneRuntime } from "./index"; |
| 7 | 7 | import { withControlPlaneClient } from "./test-http-client"; |
| @@ -312,7 +312,7 @@ describe("control-plane-runtime", () => { · 304 unmodified lines | ||
| 312 | 312 | expect(deleteOrg.removed).toBe(true); |
| 313 | 313 | |
| 314 | 314 | const deletedWorkspaceLookup = yield* Effect.either( |
| 315 | − runtime.service.getWorkspace(workspace.id as never), | |
| 315 | + runtime.service.getWorkspace(WorkspaceIdSchema.make(workspace.id)), | |
| 316 | 316 | ); |
| 317 | 317 | expect(deletedWorkspaceLookup._tag).toBe("Left"); |
| 318 | 318 | |