ff0f812e00
Pure Dart A1a artifact domain slice mirroring web/src/artifacts.js and artifactNavigation.js: record parsing, capture facts, stage/visit grouping, public attribution, kind vocabulary, summaries, viewer paging and safe artifact url resolution. Tests mirror the domain directory; nothing is wired into a screen or transport.
64 lines
2.1 KiB
Dart
64 lines
2.1 KiB
Dart
import '../../../core/api_gateway.dart';
|
|
import 'artifact_record.dart';
|
|
|
|
/// Whether a step actually carried an artifact list.
|
|
///
|
|
/// An absent (or null) field means the capture is unavailable: an older step, a
|
|
/// running visit, or a reply that did not include the field. It must never be
|
|
/// reported as an empty capture. An explicitly recorded empty list is a known,
|
|
/// empty capture.
|
|
enum ArtifactCaptureAvailability { unavailable, recorded }
|
|
|
|
/// The recorded capture facts of one step: availability, files, and how many
|
|
/// files the bounded scan excluded or omitted. Pure: it reads the step and adds
|
|
/// no server call.
|
|
class ArtifactCapture {
|
|
const ArtifactCapture._({
|
|
required this.availability,
|
|
required this.artifacts,
|
|
required this.skipped,
|
|
required this.truncated,
|
|
});
|
|
|
|
factory ArtifactCapture.fromStep(JsonMap step) {
|
|
final value = step['artifacts'];
|
|
final available = step.containsKey('artifacts') && value is List;
|
|
final artifacts = available
|
|
? <ArtifactRecord>[
|
|
for (final item in value)
|
|
if (item is Map)
|
|
ArtifactRecord.fromJson(Map<String, dynamic>.from(item)),
|
|
]
|
|
: const <ArtifactRecord>[];
|
|
return ArtifactCapture._(
|
|
availability: available
|
|
? ArtifactCaptureAvailability.recorded
|
|
: ArtifactCaptureAvailability.unavailable,
|
|
artifacts: List<ArtifactRecord>.unmodifiable(artifacts),
|
|
skipped: _countOf(step['artifacts_skipped']),
|
|
truncated: _countOf(step['artifacts_truncated']),
|
|
);
|
|
}
|
|
|
|
final ArtifactCaptureAvailability availability;
|
|
|
|
/// Every recorded file, including utility and retired files.
|
|
final List<ArtifactRecord> artifacts;
|
|
|
|
/// Files excluded from the bounded per-step scan.
|
|
final int skipped;
|
|
|
|
/// Files omitted by the capture's total budget.
|
|
final int truncated;
|
|
|
|
bool get isAvailable => availability == ArtifactCaptureAvailability.recorded;
|
|
|
|
bool get isPartial => skipped > 0 || truncated > 0;
|
|
|
|
static int _countOf(dynamic value) {
|
|
if (value is num) return value.toInt();
|
|
if (value is String) return int.tryParse(value.trim()) ?? 0;
|
|
return 0;
|
|
}
|
|
}
|