resolve method

Future<DVResolvedPrompt> resolve(
  1. String id
)

The version that answers for id: the active stored one, or else the compiled one.

Implementation

Future<DVResolvedPrompt> resolve(String id) async {
  final DVPromptVersion compiled = _compiled[id] ??
      (throw ArgumentError.value(id, 'id', 'no prompt is registered'));
  final DVPromptVersion? stored = await store.active(id);
  if (stored == null) return DVResolvedPrompt(compiled, DVPromptSource.compiled);
  if (!_hasCounterpart(stored) &&
      _reported.add('${stored.id}@${stored.version}#${stored.fingerprint}')) {
    _log.log(
      'DV-AIOPS-001: stored prompt "${stored.id}" version ${stored.version} '
      'has no counterpart in the repository; the next deploy reverts it. '
      'Export it back to source.',
      level: DVLogLevel.warn,
      code: 'DV-AIOPS-001',
      context: <String, Object?>{
        'prompt': stored.id,
        'version': stored.version,
        'fingerprint': stored.fingerprint,
      },
    );
  }
  return DVResolvedPrompt(stored, DVPromptSource.stored);
}