feat: add AI recommendations flow for tenders
Implement company AI onboarding/recommendation models, services, repository, and tender UI integration with supporting tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// ignore_for_file: invalid_annotation_target
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'recommendation_item.freezed.dart';
|
||||
part 'recommendation_item.g.dart';
|
||||
|
||||
/// A single AI tender recommendation returned by `POST /api/v1/recommend`.
|
||||
///
|
||||
/// [tenderId] is the backend tender id used with
|
||||
/// `GET /api/v1/tenders/details/:id`. [rank] is a display order string where
|
||||
/// `1` is the best match. All fields are nullable to stay resilient to partial
|
||||
/// API payloads.
|
||||
@freezed
|
||||
abstract class RecommendationItem with _$RecommendationItem {
|
||||
const factory RecommendationItem({
|
||||
required String? rank,
|
||||
@JsonKey(name: 'tender_id') required String? tenderId,
|
||||
required String? analysis,
|
||||
}) = _RecommendationItem;
|
||||
|
||||
factory RecommendationItem.fromJson(Map<String, dynamic> json) =>
|
||||
_$RecommendationItemFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'recommendation_item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$RecommendationItem {
|
||||
|
||||
String? get rank;@JsonKey(name: 'tender_id') String? get tenderId; String? get analysis;
|
||||
/// Create a copy of RecommendationItem
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$RecommendationItemCopyWith<RecommendationItem> get copyWith => _$RecommendationItemCopyWithImpl<RecommendationItem>(this as RecommendationItem, _$identity);
|
||||
|
||||
/// Serializes this RecommendationItem to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is RecommendationItem&&(identical(other.rank, rank) || other.rank == rank)&&(identical(other.tenderId, tenderId) || other.tenderId == tenderId)&&(identical(other.analysis, analysis) || other.analysis == analysis));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,rank,tenderId,analysis);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RecommendationItem(rank: $rank, tenderId: $tenderId, analysis: $analysis)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $RecommendationItemCopyWith<$Res> {
|
||||
factory $RecommendationItemCopyWith(RecommendationItem value, $Res Function(RecommendationItem) _then) = _$RecommendationItemCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String? rank,@JsonKey(name: 'tender_id') String? tenderId, String? analysis
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$RecommendationItemCopyWithImpl<$Res>
|
||||
implements $RecommendationItemCopyWith<$Res> {
|
||||
_$RecommendationItemCopyWithImpl(this._self, this._then);
|
||||
|
||||
final RecommendationItem _self;
|
||||
final $Res Function(RecommendationItem) _then;
|
||||
|
||||
/// Create a copy of RecommendationItem
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? rank = freezed,Object? tenderId = freezed,Object? analysis = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
rank: freezed == rank ? _self.rank : rank // ignore: cast_nullable_to_non_nullable
|
||||
as String?,tenderId: freezed == tenderId ? _self.tenderId : tenderId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,analysis: freezed == analysis ? _self.analysis : analysis // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [RecommendationItem].
|
||||
extension RecommendationItemPatterns on RecommendationItem {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _RecommendationItem value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _RecommendationItem() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _RecommendationItem value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _RecommendationItem():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _RecommendationItem value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _RecommendationItem() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? rank, @JsonKey(name: 'tender_id') String? tenderId, String? analysis)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _RecommendationItem() when $default != null:
|
||||
return $default(_that.rank,_that.tenderId,_that.analysis);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? rank, @JsonKey(name: 'tender_id') String? tenderId, String? analysis) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _RecommendationItem():
|
||||
return $default(_that.rank,_that.tenderId,_that.analysis);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? rank, @JsonKey(name: 'tender_id') String? tenderId, String? analysis)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _RecommendationItem() when $default != null:
|
||||
return $default(_that.rank,_that.tenderId,_that.analysis);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _RecommendationItem implements RecommendationItem {
|
||||
const _RecommendationItem({required this.rank, @JsonKey(name: 'tender_id') required this.tenderId, required this.analysis});
|
||||
factory _RecommendationItem.fromJson(Map<String, dynamic> json) => _$RecommendationItemFromJson(json);
|
||||
|
||||
@override final String? rank;
|
||||
@override@JsonKey(name: 'tender_id') final String? tenderId;
|
||||
@override final String? analysis;
|
||||
|
||||
/// Create a copy of RecommendationItem
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$RecommendationItemCopyWith<_RecommendationItem> get copyWith => __$RecommendationItemCopyWithImpl<_RecommendationItem>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$RecommendationItemToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RecommendationItem&&(identical(other.rank, rank) || other.rank == rank)&&(identical(other.tenderId, tenderId) || other.tenderId == tenderId)&&(identical(other.analysis, analysis) || other.analysis == analysis));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,rank,tenderId,analysis);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RecommendationItem(rank: $rank, tenderId: $tenderId, analysis: $analysis)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$RecommendationItemCopyWith<$Res> implements $RecommendationItemCopyWith<$Res> {
|
||||
factory _$RecommendationItemCopyWith(_RecommendationItem value, $Res Function(_RecommendationItem) _then) = __$RecommendationItemCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String? rank,@JsonKey(name: 'tender_id') String? tenderId, String? analysis
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$RecommendationItemCopyWithImpl<$Res>
|
||||
implements _$RecommendationItemCopyWith<$Res> {
|
||||
__$RecommendationItemCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _RecommendationItem _self;
|
||||
final $Res Function(_RecommendationItem) _then;
|
||||
|
||||
/// Create a copy of RecommendationItem
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? rank = freezed,Object? tenderId = freezed,Object? analysis = freezed,}) {
|
||||
return _then(_RecommendationItem(
|
||||
rank: freezed == rank ? _self.rank : rank // ignore: cast_nullable_to_non_nullable
|
||||
as String?,tenderId: freezed == tenderId ? _self.tenderId : tenderId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,analysis: freezed == analysis ? _self.analysis : analysis // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'recommendation_item.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_RecommendationItem _$RecommendationItemFromJson(Map<String, dynamic> json) =>
|
||||
_RecommendationItem(
|
||||
rank: json['rank'] as String?,
|
||||
tenderId: json['tender_id'] as String?,
|
||||
analysis: json['analysis'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RecommendationItemToJson(_RecommendationItem instance) =>
|
||||
<String, dynamic>{
|
||||
'rank': instance.rank,
|
||||
'tender_id': instance.tenderId,
|
||||
'analysis': instance.analysis,
|
||||
};
|
||||
Reference in New Issue
Block a user