orphanReportKeysFromRecords function

Set<String> orphanReportKeysFromRecords(
  1. Iterable<CustomRecord> records
)

Unions the reported-orphan keys out of a scanned record list (records of any other type are skipped). Tolerant of corrupt payloads — a broken record must never fail a session boot.

Implementation

Set<String> orphanReportKeysFromRecords(Iterable<CustomRecord> records) => {
  for (final record in records)
    if (record.customType == orphanReportRecordType)
      ...switch (record.data) {
        {'keys': final List<Object?> keys} => [
          for (final key in keys)
            if (key is String && key.isNotEmpty) key,
        ],
        _ => const <String>[],
      },
};