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

Function normalizeOpenDevice

src/client/client-normalizers.ts:193–220  ·  view source on GitHub ↗
(
  value: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

191}
192
193export function normalizeOpenDevice(
194 value: Record<string, unknown>,
195): AgentDeviceSessionDevice | undefined {
196 const platform = value.platform;
197 const id = readOptionalString(value, 'id');
198 const name = readOptionalString(value, 'device');
199 if (!isPublicPlatform(platform) || !id || !name) {
200 return undefined;
201 }
202 const target = readDeviceTarget(value, 'target');
203 const identifiers = buildDeviceIdentifiers(platform, id, name);
204 return {
205 platform,
206 target,
207 id,
208 name,
209 identifiers,
210 ios:
211 platform === 'ios'
212 ? {
213 udid: readOptionalString(value, 'device_udid') ?? id,
214 simulatorSetPath: readNullableString(value, 'ios_simulator_device_set'),
215 }
216 : undefined,
217 android:
218 platform === 'android' ? { serial: readOptionalString(value, 'serial') ?? id } : undefined,
219 };
220}
221
222export function normalizeStartupSample(value: unknown): StartupPerfSample | undefined {
223 if (!isRecord(value)) return undefined;

Callers 2

createAgentDeviceClientFunction · 0.90

Calls 5

readOptionalStringFunction · 0.90
isPublicPlatformFunction · 0.90
readDeviceTargetFunction · 0.90
buildDeviceIdentifiersFunction · 0.90
readNullableStringFunction · 0.90

Tested by

no test coverage detected