MCPcopy Create free account
hub / github.com/callstack/agent-device / materializeRemoteArtifacts

Function materializeRemoteArtifacts

src/remote/daemon-artifacts.ts:294–324  ·  view source on GitHub ↗
(
  info: DaemonArtifactEndpoint,
  req: DaemonRequest,
  response: Extract<DaemonResponse, { ok: true }>,
)

Source from the content-addressed store, hash-verified

292}
293
294export async function materializeRemoteArtifacts(
295 info: DaemonArtifactEndpoint,
296 req: DaemonRequest,
297 response: Extract<DaemonResponse, { ok: true }>,
298): Promise<DaemonResponse> {
299 const artifacts = Array.isArray(response.data?.artifacts) ? response.data.artifacts : [];
300 if (artifacts.length === 0 || !info.baseUrl) return response;
301 const nextData = response.data ? { ...response.data } : {};
302 const nextArtifacts: DaemonArtifact[] = [];
303 for (const artifact of artifacts) {
304 if (!artifact || typeof artifact !== 'object' || typeof artifact.artifactId !== 'string') {
305 nextArtifacts.push(artifact);
306 continue;
307 }
308 const localPath = resolveMaterializedArtifactPath(artifact, req);
309 await downloadRemoteArtifact({
310 baseUrl: info.baseUrl,
311 token: info.token,
312 artifactId: artifact.artifactId,
313 destinationPath: localPath,
314 requestId: req.meta?.requestId,
315 });
316 nextData[artifact.field] = localPath;
317 nextArtifacts.push({
318 ...artifact,
319 localPath,
320 });
321 }
322 nextData.artifacts = nextArtifacts;
323 return { ok: true, data: nextData };
324}
325
326function resolveMaterializedArtifactPath(artifact: DaemonArtifact, req: DaemonRequest): string {
327 if (artifact.localPath && artifact.localPath.trim().length > 0) {

Callers 1

resolveDaemonHttpResultFunction · 0.90

Calls 3

downloadRemoteArtifactFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…