(
userId: string,
org: string,
status: "active" | "pending",
role: "admin" | "member" = "member",
)
| 682 | * WorkOS scan — and `userId`'s membership in it; returns the org's slug. |
| 683 | */ |
| 684 | const seedMembership = async ( |
| 685 | userId: string, |
| 686 | org: string, |
| 687 | status: "active" | "pending", |
| 688 | role: "admin" | "member" = "member", |
| 689 | ) => { |
| 690 | const slug = await seedOrganization(org); |
| 691 | await Effect.runPromise( |
| 692 | Effect.flatMap(WorkOsMirror.asEffect(), (mirror) => |
| 693 | Effect.andThen( |
| 694 | mirror.applyOrganizationScan({ |
| 695 | organizationId: org, |
| 696 | listedAt: new Date(T1), |
| 697 | members: [], |
| 698 | }), |
| 699 | mirror.upsertMembership({ |
| 700 | id: `om_${userId}_${org}`, |
| 701 | accountId: userId, |
| 702 | organizationId: org, |
| 703 | role, |
| 704 | status, |
| 705 | updatedAt: new Date(T1), |
| 706 | }), |
| 707 | ), |
| 708 | ).pipe(Effect.provide(WorkOsMirror.Live.pipe(Layer.provide(DbService.Live))), Effect.scoped), |
| 709 | ); |
| 710 | return slug; |
| 711 | }; |
| 712 | |
| 713 | const deleteOrganizationRequest = (org: string) => |
| 714 | new Request("http://test.local/auth/delete-organization", { |
no test coverage detected