MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / v2ImportEligible

Function v2ImportEligible

apps/cloud/src/auth/v2-import.ts:71–84  ·  view source on GitHub ↗
(
  source: V2ImportSource,
  userId: string,
  organizationId: string,
)

Source from the content-addressed store, hash-verified

69 * fails: an unavailable read answers `false`.
70 */
71export 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

Callers 2

v2-import.test.tsFile · 0.90
v2ImportAnswerFunction · 0.85

Calls 1

isPaidForV2ImportFunction · 0.85

Tested by

no test coverage detected