handleValueQuery method

Future<List<Map<String, dynamic>>> handleValueQuery(
  1. String entityIdentifier,
  2. Map<String, dynamic> input
)

Runs the registered value query handler for the given entity type (#51).

Called internally when an IntentValueQuery request arrives from iOS, and can also be called directly for testing. Returns an empty list when no handler is registered (the entity simply has no value query).

Implementation

Future<List<Map<String, dynamic>>> handleValueQuery(
  String entityIdentifier,
  Map<String, dynamic> input,
) async {
  final handler = _valueQueryHandlers[entityIdentifier];
  if (handler == null) {
    return <Map<String, dynamic>>[];
  }

  try {
    return await handler(input);
  } catch (e) {
    if (e is AppIntentError) rethrow;
    debugPrint('Value query error for $entityIdentifier: $e');
    throw AppIntentError(
      code: 'query_error',
      message: 'An error occurred while running the value query.',
      details: {'entityIdentifier': entityIdentifier},
    );
  }
}