getActivityTypeFromOperationId function

String getActivityTypeFromOperationId(
  1. String operationId,
  2. Map<String, String> dynamicVersionMap
)

Determines the activity type from operation ID. Checks the static VERSIONED_ACTIVITY_TYPES map first (explicit overrides), then falls back to the dynamically-detected highest version from the swagger, and finally falls back to the unversioned base name.

Implementation

String getActivityTypeFromOperationId(
  String operationId,
  Map<String, String> dynamicVersionMap,
) {
  // Convert operationId to activity type format
  final activityTypeName = 'ACTIVITY_TYPE_${operationId.replaceAllMapped(
        RegExp(r'([A-Z])'),
        (match) => '_${match.group(1)}',
      ).toUpperCase().substring(1)}';

  // 1. Explicit static override wins
  final recordTriple = VERSIONED_ACTIVITY_TYPES[activityTypeName];
  if (recordTriple != null) return recordTriple.$1;

  // 2. Dynamically detected highest version from swagger
  final dynamic = dynamicVersionMap[activityTypeName];
  if (dynamic != null) return dynamic;

  // 3. Fall back to base type
  return activityTypeName;
}