(data: Record<string, unknown>)
| 408 | } |
| 409 | |
| 410 | function 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 | |
| 429 | export type * from './client-types.ts'; |
no test coverage detected