Configuration options for OTA model instances.

This interface defines the initial configuration for the OTA model, including any pre-existing artifact data that should be loaded during model initialization. In most cases, the OTA model will automatically load artifacts from the OTA service, but this option allows for pre-loading or testing scenarios.

Example: Basic OTA Model Creation

// Most common usage - let model load artifacts automatically
const otaModel = Ota.instance('system-updates').build();

// The model will automatically:
// - Connect to OTA service
// - Load current artifacts
// - Subscribe to real-time updates

Example: Pre-loaded Artifacts (Advanced)

// Advanced usage with pre-loaded artifact data
const mockArtifacts: OTAArtifactResponse[] = [
{
artifactInfo: {
identifier: 'system-update-v1.2.0',
name: 'System Update',
version: '1.2.0',
size: 52428800, // 50MB
hash: 'sha256:abc123...',
miniHash: 'abc123'
},
status: 'STAGED',
done: true,
requests: {
'primary': {
currentSize: 52428800,
downloaderActive: false,
downloaderName: 'system-updater',
errorCount: 0,
fileNotFoundCount: 0,
kabId: 'system-update-v1.2.0',
lastUpdateTime: Date.now()
}
}
}
];

const options: UpdaterOptions = {
otaArtifactResponse: mockArtifacts
};

const otaModel = Ota.instance('preloaded-updater')
.options(options)
.build();

Example: Testing Scenarios

// Create OTA model with test data for different scenarios
const createTestOtaModel = (scenario: 'downloading' | 'pending' | 'error') => {
const testArtifacts: OTAArtifactResponse[] = [];

switch (scenario) {
case 'downloading':
testArtifacts.push({
artifactInfo: {
identifier: 'app-update-v2.1.0',
name: 'Application Update',
version: '2.1.0',
size: 104857600, // 100MB
hash: 'sha256:def456...',
miniHash: 'def456'
},
status: 'MISSING',
done: false,
requests: {
'primary': {
currentSize: 31457280, // 30MB downloaded
downloaderActive: true,
downloaderName: 'app-updater',
errorCount: 0,
fileNotFoundCount: 0,
kabId: 'app-update-v2.1.0',
lastUpdateTime: Date.now()
}
}
});
break;

case 'pending':
testArtifacts.push({
artifactInfo: {
identifier: 'security-patch-v1.0.1',
name: 'Security Patch',
version: '1.0.1',
size: 10485760, // 10MB
hash: 'sha256:ghi789...',
miniHash: 'ghi789'
},
status: 'STAGED',
done: true,
requests: {
'primary': {
currentSize: 10485760,
downloaderActive: false,
downloaderName: 'security-updater',
errorCount: 0,
fileNotFoundCount: 0,
kabId: 'security-patch-v1.0.1',
lastUpdateTime: Date.now()
}
}
});
break;

case 'error':
testArtifacts.push({
status: 'INVALID',
done: false,
error: 'Checksum verification failed',
requests: {
'primary': {
currentSize: 0,
downloaderActive: false,
downloaderName: 'failed-updater',
errorCount: 3,
fileNotFoundCount: 0,
kabId: 'failed-update-v1.0.0',
lastUpdateTime: Date.now(),
lastErrorReason: 'Checksum verification failed'
}
}
});
break;
}

return Ota.instance(`test-${scenario}`)
.options({ otaArtifactResponse: testArtifacts })
.build();
};
interface UpdaterOptions {}