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