DVDevClientInspection.fromGraph constructor

DVDevClientInspection.fromGraph(
  1. Map<String, Object?> graph
)

Read from the project graph dartvel inspect --json prints.

Implementation

factory DVDevClientInspection.fromGraph(Map<String, Object?> graph) {
  List<Map<String, Object?>> nodes(String key) => <Map<String, Object?>>[
        for (final Object? node in graph[key] is List
            ? graph[key]! as List<Object?>
            : const <Object?>[])
          if (node is Map) node.cast<String, Object?>(),
      ];
  return DVDevClientInspection(
    routes: <String>[for (final n in nodes('routes')) '${n['path']}'],
    models: <String>[for (final n in nodes('models')) '${n['name']}'],
    functions: <String>[
      for (final n in nodes('functions')) '${n['method']} ${n['path']}',
    ],
    jobs: <String>[
      for (final n in nodes('jobs'))
        n['queue'] == null ? '${n['name']}' : '${n['name']} (${n['queue']})',
    ],
  );
}