// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../../repositories.dart';

/// Repository value plus adapter-neutral metadata.
class RepositoryRecord<T> {
  /// Creates a `RepositoryRecord` instance with the values required by its invariants.
  /// Callers should pass already-normalized scheduler data because validation and defaulting belong at the model or service boundary, not in arbitrary UI code.
  const RepositoryRecord({
    required this.value,
    required this.ownerId,
    required this.revision,
    this.archivedAt,
  });

  /// Stores the `value` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final T value;

  /// Stores the `ownerId` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final String ownerId;

  /// Stores the `revision` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final int revision;

  /// Stores the `archivedAt` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final DateTime? archivedAt;

  /// Returns the derived `isArchived` value for this object.
  /// Keeping this as an accessor gives callers a stable read surface while the owning type controls how the value is calculated.
  bool get isArchived => archivedAt != null;
}
