MCPcopy
hub / github.com/callstack/agent-device / isRemoteConnectionState

Function isRemoteConnectionState

src/remote/remote-connection-state.ts:292–315  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

290}
291
292function isRemoteConnectionState(value: unknown): value is RemoteConnectionState {
293 if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
294 const record = value as Record<string, unknown>;
295 return (
296 record.version === 1 &&
297 hasStringFields(record, [
298 'session',
299 'remoteConfigPath',
300 'remoteConfigHash',
301 'tenant',
302 'runId',
303 'connectedAt',
304 'updatedAt',
305 ]) &&
306 hasOptionalStringFields(record, [
307 'leaseId',
308 'leaseBackend',
309 'leaseProvider',
310 'deviceKey',
311 'clientId',
312 ]) &&
313 isOptionalRemoteConnectionDaemonState(record.daemon)
314 );
315}
316
317function hasStringFields(record: Record<string, unknown>, fields: string[]): boolean {
318 return fields.every((field) => typeof record[field] === 'string');

Callers 1

Calls 3

hasStringFieldsFunction · 0.85
hasOptionalStringFieldsFunction · 0.85

Tested by

no test coverage detected