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

Function normalizeLease

src/client/client.ts:410–427  ·  view source on GitHub ↗
(data: Record<string, unknown>)

Source from the content-addressed store, hash-verified

408}
409
410function normalizeLease(data: Record<string, unknown>): Lease {
411 const rawLease = data.lease;
412 if (!isRecord(rawLease)) {
413 throw new Error('Invalid lease response from daemon');
414 }
415 return {
416 leaseId: readRequiredString(rawLease, 'leaseId'),
417 tenantId: readRequiredString(rawLease, 'tenantId'),
418 runId: readRequiredString(rawLease, 'runId'),
419 backend: readRequiredString(rawLease, 'backend') as Lease['backend'],
420 leaseProvider: readOptionalString(rawLease, 'leaseProvider'),
421 clientId: readOptionalString(rawLease, 'clientId'),
422 deviceKey: readOptionalString(rawLease, 'deviceKey'),
423 createdAt: typeof rawLease.createdAt === 'number' ? rawLease.createdAt : undefined,
424 heartbeatAt: typeof rawLease.heartbeatAt === 'number' ? rawLease.heartbeatAt : undefined,
425 expiresAt: typeof rawLease.expiresAt === 'number' ? rawLease.expiresAt : undefined,
426 };
427}
428
429export type * from './client-types.ts';

Callers 1

createAgentDeviceClientFunction · 0.85

Calls 3

isRecordFunction · 0.90
readRequiredStringFunction · 0.90
readOptionalStringFunction · 0.90

Tested by

no test coverage detected