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

Function v2ImportAnswer

apps/cloud/src/auth/v2-import.ts:125–144  ·  view source on GitHub ↗
(input: {
  readonly env: V2EdgeEnv;
  readonly importSource: Effect.Effect<V2ImportSource, never, RImport>;
  readonly movedSource: Effect.Effect<V2MovedSource, never, RMoved>;
  readonly userId: string;
  readonly organizationId: string;
})

Source from the content-addressed store, hash-verified

123 * its eligibility is never read. Never fails.
124 */
125export 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 });

Callers 2

answerFunction · 0.90
handlers.tsFile · 0.90

Calls 4

v2MovedFunction · 0.90
v2AppOriginFunction · 0.85
v2ImportUrlFunction · 0.85
v2ImportEligibleFunction · 0.85

Tested by 1

answerFunction · 0.72