| 123 | * its eligibility is never read. Never fails. |
| 124 | */ |
| 125 | export const v2ImportAnswer = <RImport, RMoved>(input: { |
| 126 | readonly env: V2EdgeEnv; |
| 127 | readonly importSource: Effect.Effect<V2ImportSource, never, RImport>; |
| 128 | readonly movedSource: Effect.Effect<V2MovedSource, never, RMoved>; |
| 129 | readonly userId: string; |
| 130 | readonly organizationId: string; |
| 131 | }): Effect.Effect<V2ImportAnswer, never, RImport | RMoved> => |
| 132 | Effect.gen(function* () { |
| 133 | const v2Origin = v2AppOrigin(input.env); |
| 134 | const importUrl = v2ImportUrl(input.env); |
| 135 | if (v2Origin === null || importUrl === null) return { url: null, moved: null }; |
| 136 | const moved = yield* v2Moved(yield* input.movedSource, input.organizationId, v2Origin); |
| 137 | if (moved !== null) return { url: null, moved }; |
| 138 | const eligible = yield* v2ImportEligible( |
| 139 | yield* input.importSource, |
| 140 | input.userId, |
| 141 | input.organizationId, |
| 142 | ); |
| 143 | return { url: eligible ? importUrl.href : null, moved: null }; |
| 144 | }); |