Files
pipelines/app/lib/features/schedules/domain/schedule_json.dart
T
alan b9639650e5 feat(app): add saved-schedule repository and domain record
Port the web client's list/save/delete schedule request shapes and reply checks, with a typed record that preserves the whole server payload including unknown fields. Revision stays the CAS token; server refusals propagate unchanged.
2026-10-21 15:15:47 +01:00

23 lines
691 B
Dart

import '../../../core/api_gateway.dart';
/// Deep copy of a decoded JSON value.
///
/// Saved schedules travel back to the server unchanged, so unknown fields (and
/// unknown nested values) must survive every round trip without sharing state
/// with the reply map that produced them.
dynamic cloneJsonValue(dynamic value) {
if (value is Map) {
return <String, dynamic>{
for (final entry in value.entries)
'${entry.key}': cloneJsonValue(entry.value),
};
}
if (value is List) {
return [for (final item in value) cloneJsonValue(item)];
}
return value;
}
JsonMap cloneJsonMap(JsonMap value) =>
Map<String, dynamic>.from(cloneJsonValue(value) as Map);