resolveActionNames method

Future<List<String>> resolveActionNames(
  1. String key
)

Expands a possibly-wildcard key into the concrete keys it addresses.

A dynamic-action-provider key with a * or prefix* name expands to one key per matching action; any other resolvable key returns itself. Mirrors JS's resolveActionNames.

Implementation

Future<List<String>> resolveActionNames(String key) async {
  final parsed = parseRegistryKey(key);
  final host = parsed?.dynamicActionHost;
  if (parsed != null && host != null) {
    final dap =
        await lookupAction(.dynamicActionProvider, host)
            as DynamicActionProvider?;
    if (dap == null) return const [];
    final metas = await dap.listActionMetadata(
      parsed.actionType,
      parsed.actionName,
    );
    return metas
        .map(
          (m) =>
              '/dynamic-action-provider/$host:${parsed.actionType.value}/${m.name}',
        )
        .toList();
  }
  // Non-DAP key: it resolves to itself when the action exists, else to
  // nothing. Mirrors JS, which looks the key up before returning `[key]`.
  if (parsed != null &&
      await lookupAction(parsed.actionType, parsed.actionName) != null) {
    return [key];
  }
  return const [];
}