( source: V2ImportSource, userId: string, organizationId: string, )
| 69 | * fails: an unavailable read answers `false`. |
| 70 | */ |
| 71 | export const v2ImportEligible = ( |
| 72 | source: V2ImportSource, |
| 73 | userId: string, |
| 74 | organizationId: string, |
| 75 | ): Effect.Effect<boolean> => |
| 76 | Effect.gen(function* () { |
| 77 | if (!(yield* source.emailVerified(userId))) return false; |
| 78 | const members = yield* source.activeMemberIds(organizationId); |
| 79 | if (members.length !== 1 || members[0] !== userId) return false; |
| 80 | return !isPaidForV2Import(yield* source.subscriptions(organizationId)); |
| 81 | }).pipe( |
| 82 | Effect.orElseSucceed(() => false), |
| 83 | Effect.withSpan("v2Import.eligible"), |
| 84 | ); |
| 85 | |
| 86 | /** The reads over v1's WorkOS (live, not the membership mirror, as v2 reads |
| 87 | * them) and Autumn. Billing is read without provisioning: an organization |
no test coverage detected