web feed intermediate
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:lensai/features/web_feed/data/database/database.dart';
|
||||
import 'package:lensai/features/web_feed/data/models/feed_author.dart';
|
||||
import 'package:lensai/features/web_feed/data/models/feed_category.dart';
|
||||
import 'package:lensai/features/web_feed/data/models/feed_link.dart';
|
||||
|
||||
part 'feed_article.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class FeedArticle with FastEquatable implements Insertable<FeedArticle> {
|
||||
final String id;
|
||||
final Uri feedId;
|
||||
final DateTime fetched;
|
||||
final DateTime? created;
|
||||
final DateTime? updated;
|
||||
final DateTime? lastRead;
|
||||
final String? title;
|
||||
final List<FeedAuthor>? authors;
|
||||
final List<FeedCategory>? tags;
|
||||
final List<FeedLink>? links;
|
||||
final String? summaryMarkdown;
|
||||
final String? summaryPlain;
|
||||
final String? contentMarkdown;
|
||||
final String? contentPlain;
|
||||
|
||||
FeedArticle({
|
||||
required this.id,
|
||||
required this.feedId,
|
||||
required this.fetched,
|
||||
this.created,
|
||||
this.updated,
|
||||
this.lastRead,
|
||||
this.title,
|
||||
this.authors,
|
||||
this.tags,
|
||||
this.links,
|
||||
this.summaryMarkdown,
|
||||
this.summaryPlain,
|
||||
this.contentMarkdown,
|
||||
this.contentPlain,
|
||||
});
|
||||
|
||||
factory FeedArticle.fromJson(Map<String, dynamic> json) =>
|
||||
_$FeedArticleFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FeedArticleToJson(this);
|
||||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<String>(id);
|
||||
{
|
||||
map['feed_id'] = Variable<String>(Article.$converterfeedId.toSql(feedId));
|
||||
}
|
||||
map['fetched'] = Variable<DateTime>(fetched);
|
||||
if (!nullToAbsent || created != null) {
|
||||
map['created'] = Variable<DateTime>(created);
|
||||
}
|
||||
if (!nullToAbsent || updated != null) {
|
||||
map['updated'] = Variable<DateTime>(updated);
|
||||
}
|
||||
if (!nullToAbsent || lastRead != null) {
|
||||
map['last_read'] = Variable<DateTime>(lastRead);
|
||||
}
|
||||
if (!nullToAbsent || title != null) {
|
||||
map['title'] = Variable<String>(title);
|
||||
}
|
||||
if (!nullToAbsent || authors != null) {
|
||||
map['authors'] = Variable<String>(
|
||||
Article.$converterauthorsn.toSql(authors),
|
||||
);
|
||||
}
|
||||
if (!nullToAbsent || tags != null) {
|
||||
map['tags'] = Variable<String>(Article.$convertertagsn.toSql(tags));
|
||||
}
|
||||
if (!nullToAbsent || links != null) {
|
||||
map['links'] = Variable<String>(Article.$converterlinksn.toSql(links));
|
||||
}
|
||||
if (!nullToAbsent || summaryMarkdown != null) {
|
||||
map['summaryMarkdown'] = Variable<String>(summaryMarkdown);
|
||||
}
|
||||
if (!nullToAbsent || summaryPlain != null) {
|
||||
map['summaryPlain'] = Variable<String>(summaryPlain);
|
||||
}
|
||||
if (!nullToAbsent || contentMarkdown != null) {
|
||||
map['contentMarkdown'] = Variable<String>(contentMarkdown);
|
||||
}
|
||||
if (!nullToAbsent || contentPlain != null) {
|
||||
map['contentPlain'] = Variable<String>(contentPlain);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [
|
||||
id,
|
||||
feedId,
|
||||
fetched,
|
||||
created,
|
||||
updated,
|
||||
lastRead,
|
||||
title,
|
||||
authors,
|
||||
tags,
|
||||
links,
|
||||
summaryMarkdown,
|
||||
summaryPlain,
|
||||
contentMarkdown,
|
||||
contentPlain,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'feed_article.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
FeedArticle _$FeedArticleFromJson(Map<String, dynamic> json) => FeedArticle(
|
||||
id: json['id'] as String,
|
||||
feedId: Uri.parse(json['feedId'] as String),
|
||||
fetched: DateTime.parse(json['fetched'] as String),
|
||||
created:
|
||||
json['created'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created'] as String),
|
||||
updated:
|
||||
json['updated'] == null
|
||||
? null
|
||||
: DateTime.parse(json['updated'] as String),
|
||||
lastRead:
|
||||
json['lastRead'] == null
|
||||
? null
|
||||
: DateTime.parse(json['lastRead'] as String),
|
||||
title: json['title'] as String?,
|
||||
authors:
|
||||
(json['authors'] as List<dynamic>?)
|
||||
?.map((e) => FeedAuthor.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
tags:
|
||||
(json['tags'] as List<dynamic>?)
|
||||
?.map((e) => FeedCategory.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
links:
|
||||
(json['links'] as List<dynamic>?)
|
||||
?.map((e) => FeedLink.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
summaryMarkdown: json['summaryMarkdown'] as String?,
|
||||
summaryPlain: json['summaryPlain'] as String?,
|
||||
contentMarkdown: json['contentMarkdown'] as String?,
|
||||
contentPlain: json['contentPlain'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$FeedArticleToJson(FeedArticle instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'feedId': instance.feedId.toString(),
|
||||
'fetched': instance.fetched.toIso8601String(),
|
||||
'created': instance.created?.toIso8601String(),
|
||||
'updated': instance.updated?.toIso8601String(),
|
||||
'lastRead': instance.lastRead?.toIso8601String(),
|
||||
'title': instance.title,
|
||||
'authors': instance.authors?.map((e) => e.toJson()).toList(),
|
||||
'tags': instance.tags?.map((e) => e.toJson()).toList(),
|
||||
'links': instance.links?.map((e) => e.toJson()).toList(),
|
||||
'summaryMarkdown': instance.summaryMarkdown,
|
||||
'summaryPlain': instance.summaryPlain,
|
||||
'contentMarkdown': instance.contentMarkdown,
|
||||
'contentPlain': instance.contentPlain,
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:lensai/features/web_feed/data/models/feed_article.dart';
|
||||
|
||||
class FeedArticleQueryResult extends FeedArticle {
|
||||
final double weightedRank;
|
||||
|
||||
FeedArticleQueryResult({
|
||||
required super.id,
|
||||
required super.feedId,
|
||||
required super.fetched,
|
||||
required this.weightedRank,
|
||||
super.created,
|
||||
super.updated,
|
||||
super.lastRead,
|
||||
super.title,
|
||||
super.authors,
|
||||
super.tags,
|
||||
super.links,
|
||||
super.summaryMarkdown,
|
||||
super.summaryPlain,
|
||||
super.contentMarkdown,
|
||||
super.contentPlain,
|
||||
});
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [...super.hashParameters, weightedRank];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'feed_author.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class FeedAuthor with FastEquatable {
|
||||
final String? name;
|
||||
final String? email;
|
||||
|
||||
FeedAuthor({this.name, this.email});
|
||||
|
||||
factory FeedAuthor.fromJson(Map<String, dynamic> json) =>
|
||||
_$FeedAuthorFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FeedAuthorToJson(this);
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [name, email];
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'feed_author.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
FeedAuthor _$FeedAuthorFromJson(Map<String, dynamic> json) =>
|
||||
FeedAuthor(name: json['name'] as String?, email: json['email'] as String?);
|
||||
|
||||
Map<String, dynamic> _$FeedAuthorToJson(FeedAuthor instance) =>
|
||||
<String, dynamic>{'name': instance.name, 'email': instance.email};
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'feed_category.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class FeedCategory with FastEquatable {
|
||||
final String id;
|
||||
final String? title;
|
||||
|
||||
FeedCategory({required this.id, this.title});
|
||||
|
||||
factory FeedCategory.fromJson(Map<String, dynamic> json) =>
|
||||
_$FeedCategoryFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FeedCategoryToJson(this);
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [id, title];
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'feed_category.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
FeedCategory _$FeedCategoryFromJson(Map<String, dynamic> json) =>
|
||||
FeedCategory(id: json['id'] as String, title: json['title'] as String?);
|
||||
|
||||
Map<String, dynamic> _$FeedCategoryToJson(FeedCategory instance) =>
|
||||
<String, dynamic>{'id': instance.id, 'title': instance.title};
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
|
||||
part 'feed_filter.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
class FeedFilter with FastEquatable {
|
||||
final Uri? feedId;
|
||||
final String? query;
|
||||
final Set<String>? tags;
|
||||
|
||||
FeedFilter({this.feedId, this.query, this.tags});
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [feedId, query, tags];
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'feed_filter.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$FeedFilterCWProxy {
|
||||
FeedFilter feedId(Uri? feedId);
|
||||
|
||||
FeedFilter query(String? query);
|
||||
|
||||
FeedFilter tags(Set<String>? tags);
|
||||
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `FeedFilter(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// FeedFilter(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
FeedFilter call({Uri? feedId, String? query, Set<String>? tags});
|
||||
}
|
||||
|
||||
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfFeedFilter.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfFeedFilter.copyWith.fieldName(...)`
|
||||
class _$FeedFilterCWProxyImpl implements _$FeedFilterCWProxy {
|
||||
const _$FeedFilterCWProxyImpl(this._value);
|
||||
|
||||
final FeedFilter _value;
|
||||
|
||||
@override
|
||||
FeedFilter feedId(Uri? feedId) => this(feedId: feedId);
|
||||
|
||||
@override
|
||||
FeedFilter query(String? query) => this(query: query);
|
||||
|
||||
@override
|
||||
FeedFilter tags(Set<String>? tags) => this(tags: tags);
|
||||
|
||||
@override
|
||||
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `FeedFilter(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||
///
|
||||
/// Usage
|
||||
/// ```dart
|
||||
/// FeedFilter(...).copyWith(id: 12, name: "My name")
|
||||
/// ````
|
||||
FeedFilter call({
|
||||
Object? feedId = const $CopyWithPlaceholder(),
|
||||
Object? query = const $CopyWithPlaceholder(),
|
||||
Object? tags = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return FeedFilter(
|
||||
feedId:
|
||||
feedId == const $CopyWithPlaceholder()
|
||||
? _value.feedId
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: feedId as Uri?,
|
||||
query:
|
||||
query == const $CopyWithPlaceholder()
|
||||
? _value.query
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: query as String?,
|
||||
tags:
|
||||
tags == const $CopyWithPlaceholder()
|
||||
? _value.tags
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: tags as Set<String>?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $FeedFilterCopyWith on FeedFilter {
|
||||
/// Returns a callable class that can be used as follows: `instanceOfFeedFilter.copyWith(...)` or like so:`instanceOfFeedFilter.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$FeedFilterCWProxy get copyWith => _$FeedFilterCWProxyImpl(this);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:fast_equatable/fast_equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'feed_link.g.dart';
|
||||
|
||||
enum FeedLinkRelation {
|
||||
///an alternate representation of the entry or feed, for example a permalink to the html version of the entry, or the front page of the weblog.
|
||||
alternate,
|
||||
|
||||
///a related resource which is potentially large in size and might require special handling, for example an audio or video recording.
|
||||
enclosure,
|
||||
|
||||
///an document related to the entry or feed.
|
||||
related,
|
||||
|
||||
///the feed itself.
|
||||
self,
|
||||
|
||||
///the source of the information provided in the entry.
|
||||
via,
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class FeedLink with FastEquatable {
|
||||
final Uri uri;
|
||||
final FeedLinkRelation? relation;
|
||||
final String? title;
|
||||
|
||||
FeedLink({required this.uri, this.relation, this.title});
|
||||
|
||||
factory FeedLink.fromJson(Map<String, dynamic> json) =>
|
||||
_$FeedLinkFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FeedLinkToJson(this);
|
||||
|
||||
@override
|
||||
bool get cacheHash => true;
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [uri, relation, title];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'feed_link.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
FeedLink _$FeedLinkFromJson(Map<String, dynamic> json) => FeedLink(
|
||||
uri: Uri.parse(json['uri'] as String),
|
||||
relation: $enumDecodeNullable(_$FeedLinkRelationEnumMap, json['relation']),
|
||||
title: json['title'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$FeedLinkToJson(FeedLink instance) => <String, dynamic>{
|
||||
'uri': instance.uri.toString(),
|
||||
'relation': _$FeedLinkRelationEnumMap[instance.relation],
|
||||
'title': instance.title,
|
||||
};
|
||||
|
||||
const _$FeedLinkRelationEnumMap = {
|
||||
FeedLinkRelation.alternate: 'alternate',
|
||||
FeedLinkRelation.enclosure: 'enclosure',
|
||||
FeedLinkRelation.related: 'related',
|
||||
FeedLinkRelation.self: 'self',
|
||||
FeedLinkRelation.via: 'via',
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:lensai/features/web_feed/data/database/converters/feed_data.dart';
|
||||
import 'package:lensai/features/web_feed/data/database/database.dart';
|
||||
import 'package:lensai/features/web_feed/data/models/feed_article.dart';
|
||||
|
||||
part 'feed_parse_result.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class FeedParseResult {
|
||||
@FeedDataConverter()
|
||||
final FeedData feedData;
|
||||
final List<FeedArticle> articleData;
|
||||
|
||||
FeedParseResult({required this.feedData, required this.articleData});
|
||||
|
||||
factory FeedParseResult.fromJson(Map<String, dynamic> json) =>
|
||||
_$FeedParseResultFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FeedParseResultToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'feed_parse_result.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
FeedParseResult _$FeedParseResultFromJson(Map<String, dynamic> json) =>
|
||||
FeedParseResult(
|
||||
feedData: const FeedDataConverter().fromJson(
|
||||
json['feedData'] as Map<String, dynamic>,
|
||||
),
|
||||
articleData:
|
||||
(json['articleData'] as List<dynamic>)
|
||||
.map((e) => FeedArticle.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$FeedParseResultToJson(FeedParseResult instance) =>
|
||||
<String, dynamic>{
|
||||
'feedData': const FeedDataConverter().toJson(instance.feedData),
|
||||
'articleData': instance.articleData.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
Reference in New Issue
Block a user