diff --git a/Beam.Abstractions/Beam.Abstractions.csproj b/Beam.Abstractions/Beam.Abstractions.csproj new file mode 100644 index 0000000..bea4d88 --- /dev/null +++ b/Beam.Abstractions/Beam.Abstractions.csproj @@ -0,0 +1,16 @@ + + + + net9.0 + enable + enable + Beam.Abstract + + + + + + + + + diff --git a/Beam.Abstractions/IArticleData.cs b/Beam.Abstractions/IArticleData.cs new file mode 100644 index 0000000..b9cc6de --- /dev/null +++ b/Beam.Abstractions/IArticleData.cs @@ -0,0 +1,10 @@ +namespace Beam.Abstractions; + +public interface IArticleData : IDocumentMetaData, IEquatable { + string? Name { get; set; } + string[] Authors { get; set; } + string? Language { get; set; } + string[] Categories { get; set; } + string? Version { get; set; } + string? Description { get; set; } +} \ No newline at end of file diff --git a/Beam.Abstractions/IDataBindings.cs b/Beam.Abstractions/IDataBindings.cs new file mode 100644 index 0000000..1155eee --- /dev/null +++ b/Beam.Abstractions/IDataBindings.cs @@ -0,0 +1,27 @@ +using Beam.Dynamic; + +namespace Beam.Abstractions; + +public interface IDataBindings { + IDataProvider? Title { get; set; } + IDataProvider? Authors { get; set; } + IDataProvider? Description { get; set; } + IDataProvider? Content { get; set; } + IDataProvider? Language { get; set; } + IDataProvider? Tags { get; set; } + IDataProvider? Publisher { get; set; } + IDataProvider? PublicationDate { get; set; } + IDataProvider? ISBN { get; set; } + IDataProvider? PageCount { get; set; } + IDataProvider? CoverImage { get; set; } + IDataProvider? Series { get; set; } + IDataProvider? Edition { get; set; } + IDataProvider? Contributors { get; set; } + IDataProvider? Subjects { get; set; } + IDataProvider? Rights { get; set; } + IDataProvider? TableOfContents { get; set; } + IDataProvider? PagesDropDown { get; set; } + IDataProvider? NextPageButton { get; set; } + IDataProvider? PreviousPageButton { get; set; } + Dictionary Providers { get; set; } +} \ No newline at end of file diff --git a/Beam.Abstractions/IDataProvider.cs b/Beam.Abstractions/IDataProvider.cs new file mode 100644 index 0000000..db87588 --- /dev/null +++ b/Beam.Abstractions/IDataProvider.cs @@ -0,0 +1,14 @@ +using HtmlAgilityPack; +using System.Text.Json.Serialization; + +namespace Beam.Dynamic; + +public interface IDataProvider { + public string GetString(HtmlDocument document) + => (this as IDataProvider)?.Get(document)?.ToString() ?? ""; +} + +public interface IDataProvider : IDataProvider { + public T Get(HtmlDocument document); + //public HtmlNode? GetNode(HtmlDocument document); +} \ No newline at end of file diff --git a/Beam.Abstractions/IDocument.cs b/Beam.Abstractions/IDocument.cs new file mode 100644 index 0000000..0779c99 --- /dev/null +++ b/Beam.Abstractions/IDocument.cs @@ -0,0 +1,28 @@ +using aeqw89.DataKeys; + +namespace Beam.Abstractions; + +public interface IDocument { + /// + /// The file name of the document. Must be valid in both UNIX, + /// WINDOWS, APPLE, and ANDROID file systems. + /// + string Filename { get; } + + /// + /// Additional descriptive data + /// + IDictionary, IDocumentMetaData> MetaData { get; } + + /// + /// Retrieves the binary representation for the + /// + /// Binary representation of the + byte[] ToBytes(); + + /// + /// Retrieves the string representation for the + /// + /// String representation of the + string ToString(); +} \ No newline at end of file diff --git a/Beam.Abstractions/IDocumentMetaData.cs b/Beam.Abstractions/IDocumentMetaData.cs new file mode 100644 index 0000000..21b93df --- /dev/null +++ b/Beam.Abstractions/IDocumentMetaData.cs @@ -0,0 +1,7 @@ +using System.Text.Json; + +namespace Beam.Abstractions; + +public interface IDocumentMetaData { + string AsJson(JsonSerializerOptions? options = null); +} \ No newline at end of file diff --git a/Beam.Abstractions/IDownloadReport.cs b/Beam.Abstractions/IDownloadReport.cs new file mode 100644 index 0000000..615b92f --- /dev/null +++ b/Beam.Abstractions/IDownloadReport.cs @@ -0,0 +1,3 @@ +namespace Beam.Abstractions; + +public interface IDownloadReport { } \ No newline at end of file diff --git a/Beam.Abstractions/ILinkBuilder.cs b/Beam.Abstractions/ILinkBuilder.cs new file mode 100644 index 0000000..3e45db5 --- /dev/null +++ b/Beam.Abstractions/ILinkBuilder.cs @@ -0,0 +1,11 @@ +using Beam.Models; + +namespace Beam.Abstractions; + +public interface ILinkBuilder { + /// + /// Produces a concrete using values from an external object. + /// + /// Object providing positional values. + string Build(IReadOnlyState parameterValues); +} \ No newline at end of file diff --git a/Beam.Abstractions/IOrdered.cs b/Beam.Abstractions/IOrdered.cs new file mode 100644 index 0000000..b94ccba --- /dev/null +++ b/Beam.Abstractions/IOrdered.cs @@ -0,0 +1,6 @@ +namespace Beam.Abstractions; + +public interface IOrdered { + T Data { get; } + int Order { get; } +} \ No newline at end of file diff --git a/Beam.Abstractions/IReadOnlyState.cs b/Beam.Abstractions/IReadOnlyState.cs new file mode 100644 index 0000000..e76be02 --- /dev/null +++ b/Beam.Abstractions/IReadOnlyState.cs @@ -0,0 +1,6 @@ +namespace Beam.Models; + +public interface IReadOnlyState { + public string[] GetState(); + IReadOnlyState Copy(); +} \ No newline at end of file diff --git a/Beam.Abstractions/IResourceDictionary.cs b/Beam.Abstractions/IResourceDictionary.cs new file mode 100644 index 0000000..2e2f24b --- /dev/null +++ b/Beam.Abstractions/IResourceDictionary.cs @@ -0,0 +1,3 @@ +namespace Beam.Abstractions; + +public interface IResourceDictionary { } \ No newline at end of file diff --git a/Beam.Abstractions/IRetryReport.cs b/Beam.Abstractions/IRetryReport.cs new file mode 100644 index 0000000..d44d723 --- /dev/null +++ b/Beam.Abstractions/IRetryReport.cs @@ -0,0 +1,6 @@ +namespace Beam.Abstractions; + +public interface IRetryReport { + int TryNumber { get; } + string Link { get; } +} \ No newline at end of file diff --git a/Beam.Abstractions/IState.cs b/Beam.Abstractions/IState.cs new file mode 100644 index 0000000..1869f50 --- /dev/null +++ b/Beam.Abstractions/IState.cs @@ -0,0 +1,8 @@ +using Beam.Models; + +namespace Beam.Abstractions; + +public interface IState : IReadOnlyState { + void SetState(string[] state); + new IState Copy(); +} \ No newline at end of file diff --git a/Beam.Abstractions/IStateChangeBehaviour.cs b/Beam.Abstractions/IStateChangeBehaviour.cs new file mode 100644 index 0000000..1a5e28b --- /dev/null +++ b/Beam.Abstractions/IStateChangeBehaviour.cs @@ -0,0 +1,10 @@ +using Beam.Models; + +namespace Beam.Abstractions; + +/// +/// Defines how a url template should should be updated, in what order, and by how much +/// +public interface IStateChangeBehaviour { + public void Apply(IState state, object stimulus); +} \ No newline at end of file diff --git a/Beam.Abstractions/IStateChangerFactory.cs b/Beam.Abstractions/IStateChangerFactory.cs new file mode 100644 index 0000000..e5e95e2 --- /dev/null +++ b/Beam.Abstractions/IStateChangerFactory.cs @@ -0,0 +1,3 @@ +namespace Beam.Abstractions; + +public interface IStateChangerFactory { } \ No newline at end of file diff --git a/Beam.Abstractions/ITemplate.cs b/Beam.Abstractions/ITemplate.cs new file mode 100644 index 0000000..f87ed2e --- /dev/null +++ b/Beam.Abstractions/ITemplate.cs @@ -0,0 +1,8 @@ +using aeqw89.DataKeys; + +namespace Beam.Abstractions; + +public interface ITemplate : IKeyed { + IStateChangerFactory Factory { get; set; } + ILinkBuilder Builder { get; set; } +} \ No newline at end of file diff --git a/Beam.Abstractions/IUnitDownloader.cs b/Beam.Abstractions/IUnitDownloader.cs new file mode 100644 index 0000000..736197b --- /dev/null +++ b/Beam.Abstractions/IUnitDownloader.cs @@ -0,0 +1,7 @@ + +namespace Beam.Abstractions; + +public interface IUnitDownloader { + public int LinksPerDownload { get; } + public Task<(bool, T?)> TryDownload(IOrdered[] link, CancellationToken ct, int maximumRetryCount = 7, IProgress? tryProgress = null); +} \ No newline at end of file diff --git a/Beam/ApiCall.cs b/Beam.Api/ApiCall.cs similarity index 100% rename from Beam/ApiCall.cs rename to Beam.Api/ApiCall.cs diff --git a/Beam/ApiCallBuilder.cs b/Beam.Api/ApiCallBuilder.cs similarity index 96% rename from Beam/ApiCallBuilder.cs rename to Beam.Api/ApiCallBuilder.cs index 2a5af0c..f4f3144 100644 --- a/Beam/ApiCallBuilder.cs +++ b/Beam.Api/ApiCallBuilder.cs @@ -5,6 +5,7 @@ using System.Net; using System.Reflection.PortableExecutable; using System.Text; using System.Threading.Tasks; +using Beam.Abstractions; namespace Beam { public class ApiCallBuilder(HttpClient client) { @@ -25,10 +26,6 @@ namespace Beam { return WithUri(uri.AbsoluteUri); } - public ApiCallBuilder WithUri(SourceLink uri) { - return WithUri(uri.Link); - } - public ApiCallBuilder WithRequestData(object? data) { Data = data; return this; diff --git a/Beam/ApiCalls.cs b/Beam.Api/ApiCalls.cs similarity index 100% rename from Beam/ApiCalls.cs rename to Beam.Api/ApiCalls.cs diff --git a/Beam/ApiCallsBuilder.cs b/Beam.Api/ApiCallsBuilder.cs similarity index 100% rename from Beam/ApiCallsBuilder.cs rename to Beam.Api/ApiCallsBuilder.cs diff --git a/Beam/ApiResponse.cs b/Beam.Api/ApiResponse.cs similarity index 100% rename from Beam/ApiResponse.cs rename to Beam.Api/ApiResponse.cs diff --git a/Beam.Data/BeamDataContext.cs b/Beam.Data/BeamDataContext.cs new file mode 100644 index 0000000..84c680f --- /dev/null +++ b/Beam.Data/BeamDataContext.cs @@ -0,0 +1,50 @@ +using aeqw89.DataKeys; +using aeqw89.PersistentData; +using Beam.Dynamic; +using Beam.Models; + +namespace Beam.Data { + using BeamFile = Models.File; + + public class BeamDataContext : BaseDataDictionary { + #region Tables + public Table