MCPcopy Index your code
hub / github.com/callstack/agent-device / buildGetRecordResult

Function buildGetRecordResult

src/daemon/selector-recording.ts:35–56  ·  view source on GitHub ↗
(
  result: Record<string, unknown>,
  property: 'text' | 'attrs',
)

Source from the content-addressed store, hash-verified

33}
34
35export function buildGetRecordResult(
36 result: Record<string, unknown>,
37 property: 'text' | 'attrs',
38): Record<string, unknown> {
39 const selectorChain = Array.isArray(result.selectorChain) ? result.selectorChain : undefined;
40 const resolvedTarget = getResolvedTarget(result);
41 const ref = resolvedTarget?.kind === 'ref' ? normalizeDaemonRef(resolvedTarget.ref) : undefined;
42 const selector = resolvedTarget?.kind === 'selector' ? resolvedTarget.selector : undefined;
43 const recordedTarget = {
44 ...(ref ? { ref } : {}),
45 ...(selector ? { selector } : {}),
46 ...(selectorChain ? { selectorChain } : {}),
47 };
48 if (property === 'attrs') return recordedTarget;
49
50 const text = typeof result.text === 'string' ? result.text : '';
51 return {
52 ...recordedTarget,
53 text,
54 refLabel: compactRecordedGetRefLabel(text),
55 };
56}
57
58export function toDaemonGetData(result: Record<string, unknown>): Record<string, unknown> {
59 const target = getResolvedTarget(result);

Callers 2

dispatchGetViaRuntimeFunction · 0.90

Calls 3

getResolvedTargetFunction · 0.85
normalizeDaemonRefFunction · 0.85

Tested by

no test coverage detected