docs(dir): 📄 doc GET/POST lists vms

This commit is contained in:
Collin M. Barrett 2021-11-27 14:57:33 -06:00
parent c692aa8820
commit a19713e63f
7 changed files with 323 additions and 31 deletions

View file

@ -2,35 +2,171 @@
public record ListDetailsVm
{
/// <summary>
/// The identifier.
/// </summary>
/// <example>301</example>
public long Id { get; init; }
/// <summary>
/// The unique name in title case.
/// </summary>
/// <example>EasyList</example>
public string Name { get; init; } = default!;
/// <summary>
/// The brief description in English (preferably quoted from the project).
/// </summary>
/// <example>
/// EasyList is the primary filter list that removes most adverts from international web pages, including unwanted
/// frames, images, and objects. It is the most popular list used by many ad blockers and forms the basis of over a
/// dozen combination and supplementary filter lists.
/// </example>
public string? Description { get; init; }
public long? LicenseId { get; init; }
/// <summary>
/// The identifier of the License under which this FilterList is released.
/// </summary>
/// <example>4</example>
public long LicenseId { get; init; }
/// <summary>
/// The identifiers of the Syntaxes implemented by this FilterList.
/// </summary>
/// <example>[ 3 ]</example>
public IEnumerable<long> SyntaxIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the Languages targeted by this FilterList.
/// </summary>
/// <example>[ 37 ]</example>
public IEnumerable<long> LanguageIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the Tags applied to this FilterList.
/// </summary>
/// <example>[ 2 ]</example>
public IEnumerable<long> TagIds { get; init; } = new HashSet<long>();
/// <summary>
/// The view URLs.
/// </summary>
public IEnumerable<ViewUrlVm> ViewUrls { get; init; } = new HashSet<ViewUrlVm>();
/// <summary>
/// The URL of the home page.
/// </summary>
/// <example>https://easylist.to/</example>
public Uri? HomeUrl { get; init; }
/// <summary>
/// The URL of the Tor / Onion page.
/// </summary>
/// <example>null</example>
public Uri? OnionUrl { get; init; }
/// <summary>
/// The URL of the policy/guidelines for the types of rules this FilterList includes.
/// </summary>
/// <example>null</example>
public Uri? PolicyUrl { get; init; }
/// <summary>
/// The URL of the submission/contact form for adding rules to this FilterList.
/// </summary>
/// <example>null</example>
public Uri? SubmissionUrl { get; init; }
/// <summary>
/// The URL of the GitHub Issues page.
/// </summary>
/// <example>https://github.com/easylist/easylist/issues</example>
public Uri? IssuesUrl { get; init; }
/// <summary>
/// The URL of the forum page.
/// </summary>
/// <example>https://forums.lanik.us/viewforum.php?f=23</example>
public Uri? ForumUrl { get; init; }
/// <summary>
/// The URL of the chat room.
/// </summary>
/// <example>null</example>
public Uri? ChatUrl { get; init; }
/// <summary>
/// The email address at which the project can be contacted.
/// </summary>
/// <example>easylist@protonmail.com</example>
public string? EmailAddress { get; init; }
/// <summary>
/// The URL at which donations to the project can be made.
/// </summary>
/// <example>null</example>
public Uri? DonateUrl { get; init; }
/// <summary>
/// The identifiers of the Maintainers of this FilterList.
/// </summary>
/// <example>[ 7 ]</example>
public IEnumerable<long> MaintainerIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the FilterLists from which this FilterList was forked.
/// </summary>
/// <example>[]</example>
public IEnumerable<long> UpstreamFilterListIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the FilterLists that have been forked from this FilterList.
/// </summary>
/// <example>[ 166, 565 ]</example>
public IEnumerable<long> ForkFilterListIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the FilterLists that include this FilterList.
/// </summary>
/// <example>[]</example>
public IEnumerable<long> IncludedInFilterListIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the FilterLists that this FilterList includes.
/// </summary>
/// <example>[ 11, 13, 168 ]</example>
public IEnumerable<long> IncludesFilterListIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the FilterLists that this FilterList depends upon.
/// </summary>
/// <example>[]</example>
public IEnumerable<long> DependencyFilterListIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the FilterLists dependent upon this FilterList.
/// </summary>
/// <example>[]</example>
public IEnumerable<long> DependentFilterListIds { get; init; } = new HashSet<long>();
public record ViewUrlVm
{
/// <summary>
/// The segment number of the URL for the FilterList (for multi-part lists).
/// </summary>
/// <example>1</example>
public short SegmentNumber { get; init; }
/// <summary>
/// How primary the URL is for the FilterList segment (1 is original, 2+ is a mirror; unique per SegmentNumber)
/// </summary>
/// <example>1</example>
public short Primariness { get; init; }
/// <summary>
/// The view URL.
/// </summary>
/// <example>https://easylist.to/easylist/easylist.txt</example>
public Uri Url { get; init; } = default!;
}
}

View file

@ -2,13 +2,61 @@
public record ListVm
{
/// <summary>
/// The identifier.
/// </summary>
/// <example>301</example>
public long Id { get; init; }
/// <summary>
/// The unique name in title case.
/// </summary>
/// <example>EasyList</example>
public string Name { get; init; } = default!;
/// <summary>
/// The brief description in English (preferably quoted from the project).
/// </summary>
/// <example>
/// EasyList is the primary filter list that removes most adverts from international web pages, including unwanted
/// frames, images, and objects. It is the most popular list used by many ad blockers and forms the basis of over a
/// dozen combination and supplementary filter lists.
/// </example>
public string? Description { get; init; }
public long? LicenseId { get; init; }
/// <summary>
/// The identifier of the License under which this FilterList is released.
/// </summary>
/// <example>4</example>
public long LicenseId { get; init; }
/// <summary>
/// The identifiers of the Syntaxes implemented by this FilterList.
/// </summary>
/// <example>[ 3 ]</example>
public IEnumerable<long> SyntaxIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the Languages targeted by this FilterList.
/// </summary>
/// <example>[ 37 ]</example>
public IEnumerable<long> LanguageIds { get; init; } = new HashSet<long>();
/// <summary>
/// The identifiers of the Tags applied to this FilterList.
/// </summary>
/// <example>[ 2 ]</example>
public IEnumerable<long> TagIds { get; init; } = new HashSet<long>();
/// <summary>
/// The primary view URL.
/// </summary>
/// <example>https://easylist.to/easylist/easylist.txt</example>
public Uri? PrimaryViewUrl { get; init; }
/// <summary>
/// The identifiers of the Maintainers of this FilterList.
/// </summary>
/// <example>[ 7 ]</example>
public IEnumerable<long> MaintainerIds { get; init; } = new HashSet<long>();
}

View file

@ -59,6 +59,6 @@ public async Task<IActionResult> Create(CreateList.Command command, Cancellation
[ProducesResponseType(StatusCodes.Status404NotFound)]
public Task<IActionResult> GetDetails(long id, CancellationToken cancellationToken)
{
return CacheGetOrCreateAsync(() => _mediator.Send(new GetListDetails.Query(id), cancellationToken), id);
return CacheGetOrCreateAsync(() => _mediator.Send(new GetListDetails.Query { Id = id }, cancellationToken), id);
}
}

View file

@ -1,5 +1,4 @@
using System.ComponentModel;
using FilterLists.Directory.Domain.Aggregates.FilterLists;
using FilterLists.Directory.Domain.Aggregates.FilterLists;
using FilterLists.Directory.Domain.Aggregates.Licenses;
using FilterLists.Directory.Infrastructure.Persistence.Commands.Context;
using FluentValidation;
@ -10,26 +9,116 @@ namespace FilterLists.Directory.Application.Commands;
public static class CreateList
{
public record Command(
[property: DefaultValue("EasyList")] string Name,
IEnumerable<FilterListViewUrl> ViewUrls,
[property: DefaultValue("EasyList is the primary filter list that removes most adverts from international web pages, including unwanted frames, images, and objects. It is the most popular list used by many ad blockers and forms the basis of over a dozen combination and supplementary filter lists.")] string? Description = default,
[property: DefaultValue(4)] long? LicenseId = default,
[property: DefaultValue("https://easylist.to/")] Uri? HomeUrl = default,
[property: DefaultValue(default(Uri))] Uri? OnionUrl = default,
[property: DefaultValue(default(Uri))] Uri? PolicyUrl = default,
[property: DefaultValue(default(Uri))] Uri? SubmissionUrl = default,
[property: DefaultValue("https://github.com/easylist/easylist/issues")] Uri? IssuesUrl = default,
[property: DefaultValue("https://forums.lanik.us/viewforum.php?f=23")] Uri? ForumUrl = default,
[property: DefaultValue(default(Uri))] Uri? ChatUrl = default,
[property: DefaultValue("easylist@protonmail.com")] string? EmailAddress = default,
[property: DefaultValue(default(Uri))] Uri? DonateUrl = default,
[property: DefaultValue("Adding EasyList because I did not see it on FilterLists.com yet.")] string? CreateReason = default) : IRequest<Response>;
public record Command : IRequest<Response>
{
/// <summary>
/// The unique name in title case.
/// </summary>
/// <example>EasyList</example>
public string Name { get; init; } = default!;
public record FilterListViewUrl(
[property: DefaultValue(1)] short SegmentNumber,
[property: DefaultValue(1)] short Primariness,
[property: DefaultValue("https://easylist.to/easylist/easylist.txt")] Uri Url);
/// <summary>
/// The view URLs.
/// </summary>
public IEnumerable<FilterListViewUrl> ViewUrls { get; init; } = new HashSet<FilterListViewUrl>();
/// <summary>
/// The brief description in English (preferably quoted from the project).
/// </summary>
/// <example>
/// EasyList is the primary filter list that removes most adverts from international web pages, including unwanted
/// frames, images, and objects. It is the most popular list used by many ad blockers and forms the basis of over a
/// dozen combination and supplementary filter lists.
/// </example>
public string? Description { get; init; }
/// <summary>
/// The identifier of the License under which this FilterList is released.
/// </summary>
/// <example>4</example>
public long? LicenseId { get; init; }
/// <summary>
/// The URL of the home page.
/// </summary>
/// <example>https://easylist.to/</example>
public Uri? HomeUrl { get; init; }
/// <summary>
/// The URL of the Tor / Onion page.
/// </summary>
/// <example>null</example>
public Uri? OnionUrl { get; init; }
/// <summary>
/// The URL of the policy/guidelines for the types of rules this FilterList includes.
/// </summary>
/// <example>null</example>
public Uri? PolicyUrl { get; init; }
/// <summary>
/// The URL of the submission/contact form for adding rules to this FilterList.
/// </summary>
/// <example>null</example>
public Uri? SubmissionUrl { get; init; }
/// <summary>
/// The URL of the GitHub Issues page.
/// </summary>
/// <example>https://github.com/easylist/easylist/issues</example>
public Uri? IssuesUrl { get; init; }
/// <summary>
/// The URL of the forum page.
/// </summary>
/// <example>https://forums.lanik.us/viewforum.php?f=23</example>
public Uri? ForumUrl { get; init; }
/// <summary>
/// The URL of the chat room.
/// </summary>
/// <example>null</example>
public Uri? ChatUrl { get; init; }
/// <summary>
/// The email address at which the project can be contacted.
/// </summary>
/// <example>easylist@protonmail.com</example>
public string? EmailAddress { get; init; }
/// <summary>
/// The URL at which donations to the project can be made.
/// </summary>
/// <example>null</example>
public Uri? DonateUrl { get; init; }
/// <summary>
/// The reason that the FilterList is being added to FilterLists.
/// </summary>
/// <example>Adding EasyList because I did not see it on FilterLists.com yet.</example>
public string? CreateReason { get; init; }
}
public record FilterListViewUrl
{
/// <summary>
/// The segment number of the URL for the FilterList (for multi-part lists).
/// </summary>
/// <example>1</example>
public short SegmentNumber { get; init; }
/// <summary>
/// How primary the URL is for the FilterList segment (1 is original, 2+ is a mirror; unique per SegmentNumber)
/// </summary>
/// <example>1</example>
public short Primariness { get; init; }
/// <summary>
/// The view URL.
/// </summary>
/// <example>https://easylist.to/easylist/easylist.txt</example>
public Uri Url { get; init; } = default!;
}
internal class Validator : AbstractValidator<Command>
{
@ -80,9 +169,21 @@ public async Task<Response> Handle(Command request, CancellationToken cancellati
await _commandContext.SaveChangesAsync(cancellationToken);
return new Response(filterList.Changes.Single().Id);
return new Response
{
ChangeId =
filterList.Changes.Single()
.Id
};
}
}
public record Response(long ChangeId) { }
public record Response
{
/// <summary>
/// The identifier of the Change for the new FilterList.
/// </summary>
/// <example>99</example>
public long ChangeId { get; init; }
}
}

View file

@ -53,13 +53,13 @@ public record LanguageVm
public long Id { get; private init; }
/// <summary>
/// The ISO 639-1 code.
/// The unique ISO 639-1 code.
/// </summary>
/// <example>en</example>
public string Iso6391 { get; private init; } = default!;
/// <summary>
/// The ISO name.
/// The unique ISO name.
/// </summary>
/// <example>English</example>
public string Name { get; private init; } = default!;

View file

@ -51,7 +51,7 @@ public record LicenseVm
public long Id { get; private init; }
/// <summary>
/// The name.
/// The unique name.
/// </summary>
/// <example>All Rights Reserved</example>
public string Name { get; private init; } = default!;

View file

@ -11,14 +11,21 @@ namespace FilterLists.Directory.Application.Queries;
public static class GetListDetails
{
public record Query(long Id) : IRequest<ListDetailsVm?>;
public record Query : IRequest<ListDetailsVm?>
{
/// <summary>
/// The identifier.
/// </summary>
/// <example>301</example>
public long Id { get; init; }
}
internal class Validator : AbstractValidator<Query>
{
public Validator()
{
RuleFor(q => q.Id)
.GreaterThanOrEqualTo(0);
.GreaterThan(0);
}
}