diff --git a/Directory.Packages.props b/Directory.Packages.props index 8ce2c1c..6d5f641 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,8 +6,8 @@ - - + + @@ -29,11 +29,11 @@ - + - - + + @@ -41,16 +41,16 @@ - - + + - + - + diff --git a/Integration/Chronicle/for_Diagnose/when_diagnosing_server.cs b/Integration/Chronicle/for_Diagnose/when_diagnosing_server.cs new file mode 100644 index 0000000..311cd80 --- /dev/null +++ b/Integration/Chronicle/for_Diagnose/when_diagnosing_server.cs @@ -0,0 +1,21 @@ +// Copyright (c) Cratis. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using context = Cratis.Cli.Integration.Chronicle.for_Diagnose.when_diagnosing_server.context; + +namespace Cratis.Cli.Integration.Chronicle.for_Diagnose; + +[Collection(ChronicleCollection.Name)] +public class when_diagnosing_server(context context) : CliGiven(context) +{ + public class context : given.a_connected_cli + { + public CliCommandResult Result = null!; + + async Task Because() => Result = await RunCliAsync("chronicle", "diagnose"); + } + + [Fact] void should_include_event_stores() => Context.Result.StandardOutput.ShouldContain("\"eventStores\": ["); + [Fact] void should_include_the_system_event_store() => Context.Result.StandardOutput.ShouldContain("System"); + [Fact] void should_have_no_errors() => Context.Result.StandardError.ShouldEqual(string.Empty); +} diff --git a/Source/Cli.Generators/Cli.Generators.csproj b/Source/Cli.Generators/Cli.Generators.csproj index bfb91a8..6952887 100644 --- a/Source/Cli.Generators/Cli.Generators.csproj +++ b/Source/Cli.Generators/Cli.Generators.csproj @@ -24,6 +24,6 @@ - + diff --git a/Source/Cli/Commands/Chronicle/Applications/AddApplicationCommand.cs b/Source/Cli/Commands/Chronicle/Applications/AddApplicationCommand.cs index d35e71d..d56fc24 100644 --- a/Source/Cli/Commands/Chronicle/Applications/AddApplicationCommand.cs +++ b/Source/Cli/Commands/Chronicle/Applications/AddApplicationCommand.cs @@ -17,9 +17,9 @@ public class AddApplicationCommand : ChronicleCommand /// protected override async Task ExecuteCommandAsync(IServices services, AddApplicationSettings settings, string format) { - await services.Applications.Add(new AddApplication + await services.Applications.AddApplication(new AddApplicationRequest { - Id = Guid.NewGuid().ToString(), + Id = Guid.NewGuid(), ClientId = settings.ClientId, ClientSecret = settings.ClientSecret }); diff --git a/Source/Cli/Commands/Chronicle/Applications/ListApplicationsCommand.cs b/Source/Cli/Commands/Chronicle/Applications/ListApplicationsCommand.cs index 2ac77ab..849ea6e 100644 --- a/Source/Cli/Commands/Chronicle/Applications/ListApplicationsCommand.cs +++ b/Source/Cli/Commands/Chronicle/Applications/ListApplicationsCommand.cs @@ -1,6 +1,8 @@ // Copyright (c) Cratis. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Reactive.Linq; + namespace Cratis.Cli.Commands.Chronicle.Applications; /// @@ -15,7 +17,8 @@ public class ListApplicationsCommand : ChronicleCommand /// protected override async Task ExecuteCommandAsync(IServices services, EventStoreSettings settings, string format) { - var applications = await services.Applications.GetAll(); + var result = await services.Applications.AllApplications().FirstAsync(); + var applications = result.Data ?? []; OutputFormatter.Write( format, diff --git a/Source/Cli/Commands/Chronicle/Applications/RemoveApplicationCommand.cs b/Source/Cli/Commands/Chronicle/Applications/RemoveApplicationCommand.cs index 2149b7f..2731374 100644 --- a/Source/Cli/Commands/Chronicle/Applications/RemoveApplicationCommand.cs +++ b/Source/Cli/Commands/Chronicle/Applications/RemoveApplicationCommand.cs @@ -22,7 +22,7 @@ protected override async Task ExecuteCommandAsync(IServices services, Remov return ExitCodes.Success; } - await services.Applications.Remove(new RemoveApplication + await services.Applications.RemoveApplication(new RemoveApplicationRequest { Id = settings.AppId }); diff --git a/Source/Cli/Commands/Chronicle/Diagnose/DiagnoseCommand.cs b/Source/Cli/Commands/Chronicle/Diagnose/DiagnoseCommand.cs index 5527b84..7a82dbe 100644 --- a/Source/Cli/Commands/Chronicle/Diagnose/DiagnoseCommand.cs +++ b/Source/Cli/Commands/Chronicle/Diagnose/DiagnoseCommand.cs @@ -84,7 +84,8 @@ static async Task Gather(IServices services, DiagnoseSettings sett var eventStores = new List(); try { - eventStores = [.. await services.EventStores.GetEventStores()]; + var result = await services.EventStores.AllEventStores(); + eventStores = [.. result.Data ?? []]; } catch { } diff --git a/Source/Cli/Commands/Chronicle/EventStoreSelector.cs b/Source/Cli/Commands/Chronicle/EventStoreSelector.cs index 46a8c09..17be502 100644 --- a/Source/Cli/Commands/Chronicle/EventStoreSelector.cs +++ b/Source/Cli/Commands/Chronicle/EventStoreSelector.cs @@ -50,7 +50,7 @@ public static EventStoreSelectorResult TryPromptAndSave( string? currentEventStore = null) { // Use Task.Run to execute the async connection and gRPC call in a clean thread-pool context. - // Calling ConnectSync (blocking) followed by GetEventStores().GetAwaiter().GetResult() from a + // Calling ConnectSync (blocking) followed by AllEventStores().GetAwaiter().GetResult() from a // thread that itself was resumed from a blocked GetResult() call can cause deadlocks with the // gRPC channel's internal completion machinery. Task.Run gives us a fresh context with no // blocked thread in the chain. @@ -60,7 +60,8 @@ public static EventStoreSelectorResult TryPromptAndSave( eventStores = Task.Run(async () => { using var client = await CliChronicleConnection.Connect(connectionString); - return (await client.Services.EventStores.GetEventStores()).ToList(); + var result = await client.Services.EventStores.AllEventStores(); + return (result.Data ?? []).ToList(); }).GetAwaiter().GetResult(); } catch diff --git a/Source/Cli/Commands/Chronicle/EventStores/ListEventStoresCommand.cs b/Source/Cli/Commands/Chronicle/EventStores/ListEventStoresCommand.cs index f8f898b..7dbf286 100644 --- a/Source/Cli/Commands/Chronicle/EventStores/ListEventStoresCommand.cs +++ b/Source/Cli/Commands/Chronicle/EventStores/ListEventStoresCommand.cs @@ -15,8 +15,8 @@ public class ListEventStoresCommand : ChronicleCommand /// protected override async Task ExecuteCommandAsync(IServices services, ChronicleSettings settings, string format) { - var eventStores = await services.EventStores.GetEventStores(); - var names = eventStores.ToList(); + var eventStores = await services.EventStores.AllEventStores(); + var names = (eventStores.Data ?? []).ToList(); OutputFormatter.Write( format, diff --git a/Source/Cli/Commands/Chronicle/Jobs/GetJobCommand.cs b/Source/Cli/Commands/Chronicle/Jobs/GetJobCommand.cs index 21b2bce..21b474d 100644 --- a/Source/Cli/Commands/Chronicle/Jobs/GetJobCommand.cs +++ b/Source/Cli/Commands/Chronicle/Jobs/GetJobCommand.cs @@ -23,14 +23,13 @@ protected override async Task ExecuteCommandAsync(IServices services, JobCo return ExitCodes.ValidationError; } - var result = await services.Jobs.GetJob(new GetJobRequest + var result = await services.Jobs.AllJobs(new AllJobsRequest { EventStore = settings.ResolveEventStore(), - Namespace = settings.ResolveNamespace(), - JobId = jobId + Namespace = settings.ResolveNamespace() }); - var job = result.Value0; + var job = result.Data?.SingleOrDefault(job => job.Id == jobId); if (job is null) { @@ -65,7 +64,7 @@ protected override async Task ExecuteCommandAsync(IServices services, JobCo isCompleted = job.Progress?.IsCompleted, message = job.Progress?.Message }, - steps = (steps ?? []).Select(s => new + steps = (steps.Data ?? []).Select(s => new { id = s.Id, type = s.Type, diff --git a/Source/Cli/Commands/Chronicle/Jobs/ListJobsCommand.cs b/Source/Cli/Commands/Chronicle/Jobs/ListJobsCommand.cs index 13bddf3..db5e7b7 100644 --- a/Source/Cli/Commands/Chronicle/Jobs/ListJobsCommand.cs +++ b/Source/Cli/Commands/Chronicle/Jobs/ListJobsCommand.cs @@ -16,13 +16,13 @@ public class ListJobsCommand : ChronicleCommand /// protected override async Task ExecuteCommandAsync(IServices services, JobsSettings settings, string format) { - var jobs = await services.Jobs.GetJobs(new GetJobsRequest + var jobs = await services.Jobs.AllJobs(new AllJobsRequest { EventStore = settings.ResolveEventStore(), Namespace = settings.ResolveNamespace() }); - var jobList = (jobs ?? []).ToList(); + var jobList = (jobs.Data ?? []).ToList(); OutputFormatter.Write( format, diff --git a/Source/Cli/Commands/Chronicle/Jobs/ResumeJobCommand.cs b/Source/Cli/Commands/Chronicle/Jobs/ResumeJobCommand.cs index 324dbf7..5f12428 100644 --- a/Source/Cli/Commands/Chronicle/Jobs/ResumeJobCommand.cs +++ b/Source/Cli/Commands/Chronicle/Jobs/ResumeJobCommand.cs @@ -23,7 +23,7 @@ protected override async Task ExecuteCommandAsync(IServices services, JobCo return ExitCodes.ValidationError; } - await services.Jobs.Resume(new ResumeJob + await services.Jobs.ResumeJob(new ResumeJobRequest { EventStore = settings.ResolveEventStore(), Namespace = settings.ResolveNamespace(), diff --git a/Source/Cli/Commands/Chronicle/Jobs/StopJobCommand.cs b/Source/Cli/Commands/Chronicle/Jobs/StopJobCommand.cs index d5d98f5..6caf630 100644 --- a/Source/Cli/Commands/Chronicle/Jobs/StopJobCommand.cs +++ b/Source/Cli/Commands/Chronicle/Jobs/StopJobCommand.cs @@ -23,7 +23,7 @@ protected override async Task ExecuteCommandAsync(IServices services, JobCo return ExitCodes.ValidationError; } - await services.Jobs.Stop(new StopJob + await services.Jobs.StopJob(new StopJobRequest { EventStore = settings.ResolveEventStore(), Namespace = settings.ResolveNamespace(), diff --git a/Source/Cli/Commands/Chronicle/Namespaces/ListNamespacesCommand.cs b/Source/Cli/Commands/Chronicle/Namespaces/ListNamespacesCommand.cs index cabae00..6eb3bce 100644 --- a/Source/Cli/Commands/Chronicle/Namespaces/ListNamespacesCommand.cs +++ b/Source/Cli/Commands/Chronicle/Namespaces/ListNamespacesCommand.cs @@ -1,6 +1,8 @@ // Copyright (c) Cratis. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using Cratis.Chronicle.Contracts.Namespaces; + namespace Cratis.Cli.Commands.Chronicle.Namespaces; /// @@ -16,8 +18,8 @@ public class ListNamespacesCommand : ChronicleCommand /// protected override async Task ExecuteCommandAsync(IServices services, EventStoreSettings settings, string format) { - var namespaces = await services.Namespaces.GetNamespaces(new GetNamespacesRequest { EventStore = settings.ResolveEventStore() }); - var names = namespaces.ToList(); + var namespaces = await services.Namespaces.AllNamespaces(new AllNamespacesRequest { EventStore = settings.ResolveEventStore() }); + var names = (namespaces.Data ?? []).ToList(); OutputFormatter.Write( format, diff --git a/Source/Cli/Commands/Chronicle/Users/AddUserCommand.cs b/Source/Cli/Commands/Chronicle/Users/AddUserCommand.cs index aafab59..6da0229 100644 --- a/Source/Cli/Commands/Chronicle/Users/AddUserCommand.cs +++ b/Source/Cli/Commands/Chronicle/Users/AddUserCommand.cs @@ -18,7 +18,7 @@ public class AddUserCommand : ChronicleCommand /// protected override async Task ExecuteCommandAsync(IServices services, AddUserSettings settings, string format) { - await services.Users.Add(new AddUser + await services.Users.AddUser(new AddUserRequest { UserId = Guid.NewGuid(), Username = settings.Username, diff --git a/Source/Cli/Commands/Chronicle/Users/ListUsersCommand.cs b/Source/Cli/Commands/Chronicle/Users/ListUsersCommand.cs index 0589d12..6aa50b7 100644 --- a/Source/Cli/Commands/Chronicle/Users/ListUsersCommand.cs +++ b/Source/Cli/Commands/Chronicle/Users/ListUsersCommand.cs @@ -1,6 +1,8 @@ // Copyright (c) Cratis. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Reactive.Linq; + namespace Cratis.Cli.Commands.Chronicle.Users; /// @@ -15,7 +17,8 @@ public class ListUsersCommand : ChronicleCommand /// protected override async Task ExecuteCommandAsync(IServices services, EventStoreSettings settings, string format) { - var users = await services.Users.GetAll(); + var result = await services.Users.AllUsers().FirstAsync(); + var users = result.Data ?? []; OutputFormatter.Write( format, diff --git a/Source/Cli/Commands/Chronicle/Users/RemoveUserCommand.cs b/Source/Cli/Commands/Chronicle/Users/RemoveUserCommand.cs index 94a8971..ac87398 100644 --- a/Source/Cli/Commands/Chronicle/Users/RemoveUserCommand.cs +++ b/Source/Cli/Commands/Chronicle/Users/RemoveUserCommand.cs @@ -22,7 +22,7 @@ protected override async Task ExecuteCommandAsync(IServices services, Remov return ExitCodes.Success; } - await services.Users.Remove(new RemoveUser + await services.Users.RemoveUser(new RemoveUserRequest { UserId = settings.UserId }); diff --git a/Source/Cli/Commands/Chronicle/Workbench/WorkbenchData.cs b/Source/Cli/Commands/Chronicle/Workbench/WorkbenchData.cs index 75f0b22..9b61168 100644 --- a/Source/Cli/Commands/Chronicle/Workbench/WorkbenchData.cs +++ b/Source/Cli/Commands/Chronicle/Workbench/WorkbenchData.cs @@ -62,7 +62,7 @@ public record WorkbenchData( IReadOnlyList EventStoreNames, IReadOnlyList Observers, IReadOnlyList FailedPartitions, - IReadOnlyList Jobs, + IReadOnlyList Jobs, IReadOnlyList Recommendations, ulong? TailSequenceNumber, DateTimeOffset CapturedAt, @@ -76,8 +76,8 @@ public record WorkbenchData( IReadOnlyList ReadModelInstances, int ReadModelInstancesTotalCount, string? ReadModelInstancesError, - IReadOnlyList Applications, - IReadOnlyList Users, + IReadOnlyList Applications, + IReadOnlyList Users, IReadOnlyList Identities, IReadOnlyList EventStoreSubscriptions) { diff --git a/Source/Cli/Commands/Chronicle/Workbench/WorkbenchDataService.cs b/Source/Cli/Commands/Chronicle/Workbench/WorkbenchDataService.cs index 573b363..4b3beb0 100644 --- a/Source/Cli/Commands/Chronicle/Workbench/WorkbenchDataService.cs +++ b/Source/Cli/Commands/Chronicle/Workbench/WorkbenchDataService.cs @@ -1,9 +1,11 @@ // Copyright (c) Cratis. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Reactive.Linq; using System.Text.Json; using Cratis.Chronicle.Contracts.Identities; using Cratis.Chronicle.Contracts.Jobs; +using Cratis.Chronicle.Contracts.Namespaces; using Cratis.Chronicle.Contracts.Observation.EventStoreSubscriptions; using Cratis.Cli.Commands.Chronicle.ReadModels; @@ -165,7 +167,11 @@ public async Task> FetchNewEventsAsync( async Task> FetchEventStoresAsync() { - try { return [.. await services.EventStores.GetEventStores().ConfigureAwait(false)]; } + try + { + var result = await services.EventStores.AllEventStores().ConfigureAwait(false); + return [.. result.Data ?? []]; + } catch { return []; } } @@ -195,15 +201,16 @@ async Task> FetchFailedPartitionsAsync(string eve catch { return []; } } - async Task> FetchJobsAsync(string eventStore, string ns) + async Task> FetchJobsAsync(string eventStore, string ns) { try { - return [.. (await services.Jobs.GetJobs(new GetJobsRequest + var result = await services.Jobs.AllJobs(new AllJobsRequest { EventStore = eventStore, Namespace = ns - }).ConfigureAwait(false)) ?? []]; + }).ConfigureAwait(false); + return [.. result.Data ?? []]; } catch { return []; } } @@ -309,21 +316,30 @@ async Task> FetchNamespacesAsync(string eventStore) { try { - return [.. await services.Namespaces.GetNamespaces( - new GetNamespacesRequest { EventStore = eventStore }).ConfigureAwait(false)]; + var result = await services.Namespaces.AllNamespaces( + new AllNamespacesRequest { EventStore = eventStore }).ConfigureAwait(false); + return [.. result.Data ?? []]; } catch { return []; } } - async Task> FetchApplicationsAsync() + async Task> FetchApplicationsAsync() { - try { return [.. await services.Applications.GetAll().ConfigureAwait(false) ?? []]; } + try + { + var result = await services.Applications.AllApplications().FirstAsync(); + return [.. result.Data ?? []]; + } catch { return []; } } - async Task> FetchUsersAsync() + async Task> FetchUsersAsync() { - try { return [.. await services.Users.GetAll().ConfigureAwait(false) ?? []]; } + try + { + var result = await services.Users.AllUsers().FirstAsync(); + return [.. result.Data ?? []]; + } catch { return []; } } diff --git a/Source/Cli/Commands/Chronicle/Workbench/views/ApplicationsView.cs b/Source/Cli/Commands/Chronicle/Workbench/views/ApplicationsView.cs index f1943be..6eae05f 100644 --- a/Source/Cli/Commands/Chronicle/Workbench/views/ApplicationsView.cs +++ b/Source/Cli/Commands/Chronicle/Workbench/views/ApplicationsView.cs @@ -1,7 +1,6 @@ // Copyright (c) Cratis. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using Cratis.Chronicle.Contracts.Security; using SharpConsoleUI.Layout; namespace Cratis.Cli.Commands.Chronicle.Workbench; @@ -9,7 +8,7 @@ namespace Cratis.Cli.Commands.Chronicle.Workbench; /// /// Applications navigation item — filterable table of registered OAuth applications with a detail pane. /// -public class ApplicationsView : FilterableTableView +public class ApplicationsView : FilterableTableView { /// protected override IReadOnlyList<(string Name, TextJustification Justify, int? Width)> Columns => @@ -29,14 +28,14 @@ public class ApplicationsView : FilterableTableView protected override string EmptyStateMessage => "No applications registered."; /// - protected override IEnumerable GetItems(WorkbenchData data) => + protected override IEnumerable GetItems(WorkbenchData data) => data.Applications.OrderBy(a => a.ClientId); /// - protected override string GetKey(Application item) => item.Id.ToString(); + protected override string GetKey(ApplicationResponse item) => item.Id.ToString(); /// - protected override string[] BuildRow(Application item) + protected override string[] BuildRow(ApplicationResponse item) { var activeColor = item.IsActive ? Theme.Success.ToMarkup() : Theme.Muted.ToMarkup(); return @@ -48,7 +47,7 @@ protected override string[] BuildRow(Application item) } /// - protected override string RenderDetail(Application? item, WorkbenchData? data) + protected override string RenderDetail(ApplicationResponse? item, WorkbenchData? data) { if (item is null) { @@ -68,7 +67,7 @@ protected override string RenderDetail(Application? item, WorkbenchData? data) } /// - protected override bool MatchesFilter(Application item, string filter) => + protected override bool MatchesFilter(ApplicationResponse item, string filter) => item.ClientId.Contains(filter, StringComparison.OrdinalIgnoreCase) || item.Id.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase); } diff --git a/Source/Cli/Commands/Chronicle/Workbench/views/JobsView.cs b/Source/Cli/Commands/Chronicle/Workbench/views/JobsView.cs index aeb803d..0702893 100644 --- a/Source/Cli/Commands/Chronicle/Workbench/views/JobsView.cs +++ b/Source/Cli/Commands/Chronicle/Workbench/views/JobsView.cs @@ -9,10 +9,10 @@ namespace Cratis.Cli.Commands.Chronicle.Workbench; /// /// Jobs tab — filterable table of background jobs with stop/resume actions in the detail pane. /// -public class JobsView : FilterableTableView +public class JobsView : FilterableTableView { /// Gets the currently selected job, or if none is selected. - public Job? SelectedJob => SelectedItem; + public JobSummaryResponse? SelectedJob => SelectedItem; /// public override string ViewHelp => @@ -25,27 +25,27 @@ public class JobsView : FilterableTableView /// /// Gets or sets the callback invoked when the user requests to stop a job. /// - public Action? OnStopJob { get; set; } + public Action? OnStopJob { get; set; } /// /// Gets or sets the callback invoked when the user requests to resume a job. /// - public Action? OnResumeJob { get; set; } + public Action? OnResumeJob { get; set; } /// /// Gets or sets the callback invoked when the user requests a bulk stop of all checked jobs. /// - public Action>? OnStopAll { get; set; } + public Action>? OnStopAll { get; set; } /// /// Gets or sets the callback invoked when the user requests a bulk resume of all checked jobs. /// - public Action>? OnResumeAll { get; set; } + public Action>? OnResumeAll { get; set; } /// /// Gets all jobs that are currently checked (checkbox mode). /// - public IReadOnlyList Checked => CheckedItems; + public IReadOnlyList Checked => CheckedItems; /// protected override IReadOnlyList<(string Name, TextJustification Justify, int? Width)> Columns => @@ -95,14 +95,14 @@ protected override IReadOnlyList GetToolbarActionTemplate() } /// - protected override IEnumerable GetItems(WorkbenchData data) => + protected override IEnumerable GetItems(WorkbenchData data) => data.Jobs.OrderBy(j => j.Status.ToString()); /// - protected override string GetKey(Job item) => item.Id.ToString(); + protected override string GetKey(JobSummaryResponse item) => item.Id.ToString(); /// - protected override string[] BuildRow(Job item) + protected override string[] BuildRow(JobSummaryResponse item) { var statusColor = GetJobStatusColor(item.Status); return @@ -114,7 +114,7 @@ protected override string[] BuildRow(Job item) } /// - protected override string RenderDetail(Job? item, WorkbenchData? data) + protected override string RenderDetail(JobSummaryResponse? item, WorkbenchData? data) { if (item is null) { @@ -157,7 +157,7 @@ protected override string RenderDetail(Job? item, WorkbenchData? data) } /// - protected override bool MatchesFilter(Job item, string filter) => + protected override bool MatchesFilter(JobSummaryResponse item, string filter) => (item.Type ?? string.Empty).Contains(filter, StringComparison.OrdinalIgnoreCase) || item.Id.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase) || item.Status.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase); diff --git a/Source/Cli/Commands/Chronicle/Workbench/views/UsersView.cs b/Source/Cli/Commands/Chronicle/Workbench/views/UsersView.cs index e4d19f6..9003518 100644 --- a/Source/Cli/Commands/Chronicle/Workbench/views/UsersView.cs +++ b/Source/Cli/Commands/Chronicle/Workbench/views/UsersView.cs @@ -8,7 +8,7 @@ namespace Cratis.Cli.Commands.Chronicle.Workbench; /// /// Users navigation item — filterable table of registered users with a detail pane. /// -public class UsersView : FilterableTableView +public class UsersView : FilterableTableView { /// protected override IReadOnlyList<(string Name, TextJustification Justify, int? Width)> Columns => @@ -28,14 +28,14 @@ public class UsersView : FilterableTableView protected override string EmptyStateMessage => "No users."; /// - protected override IEnumerable GetItems(WorkbenchData data) => + protected override IEnumerable GetItems(WorkbenchData data) => data.Users.OrderBy(u => u.Username); /// - protected override string GetKey(User item) => item.Id.ToString(); + protected override string GetKey(UserResponse item) => item.Id.ToString(); /// - protected override string[] BuildRow(User item) + protected override string[] BuildRow(UserResponse item) { var activeColor = item.IsActive ? Theme.Success.ToMarkup() : Theme.Muted.ToMarkup(); return @@ -47,7 +47,7 @@ protected override string[] BuildRow(User item) } /// - protected override string RenderDetail(User? item, WorkbenchData? data) + protected override string RenderDetail(UserResponse? item, WorkbenchData? data) { if (item is null) { @@ -69,7 +69,7 @@ protected override string RenderDetail(User? item, WorkbenchData? data) } /// - protected override bool MatchesFilter(User item, string filter) => + protected override bool MatchesFilter(UserResponse item, string filter) => item.Username.Contains(filter, StringComparison.OrdinalIgnoreCase) || (item.Email ?? string.Empty).Contains(filter, StringComparison.OrdinalIgnoreCase) || item.Id.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase); diff --git a/Source/Cli/Commands/Chronicle/Workbench/windows/MainWindow.cs b/Source/Cli/Commands/Chronicle/Workbench/windows/MainWindow.cs index f70c0ca..dc146c1 100644 --- a/Source/Cli/Commands/Chronicle/Workbench/windows/MainWindow.cs +++ b/Source/Cli/Commands/Chronicle/Workbench/windows/MainWindow.cs @@ -2,8 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Cratis.Chronicle.Contracts.Jobs; -using Cratis.Chronicle.Contracts.Observation; -using Cratis.Chronicle.Contracts.Recommendations; using SharpConsoleUI; using SharpConsoleUI.Builders; using SharpConsoleUI.Helpers; @@ -344,7 +342,7 @@ void WireViewCallbacks() { jv.OnStopJob = job => _actionHandler!.ExecuteAction( $"Stop job '{TruncateId(job.Type ?? job.Id.ToString())}'", - () => services.Jobs.Stop(new StopJob + () => services.Jobs.StopJob(new StopJobRequest { EventStore = ActiveEventStore, Namespace = ActiveNamespace, @@ -353,7 +351,7 @@ void WireViewCallbacks() jv.OnResumeJob = job => _actionHandler!.ExecuteAction( $"Resume job '{TruncateId(job.Type ?? job.Id.ToString())}'", - () => services.Jobs.Resume(new ResumeJob + () => services.Jobs.ResumeJob(new ResumeJobRequest { EventStore = ActiveEventStore, Namespace = ActiveNamespace, @@ -363,7 +361,7 @@ void WireViewCallbacks() jv.OnStopAll = jobs => _actionHandler!.ConfirmThenExecuteAll( $"Stop {jobs.Count} job{(jobs.Count == 1 ? string.Empty : "s")}", jobs, - job => services.Jobs.Stop(new StopJob + job => services.Jobs.StopJob(new StopJobRequest { EventStore = ActiveEventStore, Namespace = ActiveNamespace, @@ -374,7 +372,7 @@ void WireViewCallbacks() jv.OnResumeAll = jobs => _actionHandler!.ConfirmThenExecuteAll( $"Resume {jobs.Count} job{(jobs.Count == 1 ? string.Empty : "s")}", jobs, - job => services.Jobs.Resume(new ResumeJob + job => services.Jobs.ResumeJob(new ResumeJobRequest { EventStore = ActiveEventStore, Namespace = ActiveNamespace, diff --git a/Source/Cli/Commands/Completions/DynamicCompleteCommand.cs b/Source/Cli/Commands/Completions/DynamicCompleteCommand.cs index 6524eb9..5cdde52 100644 --- a/Source/Cli/Commands/Completions/DynamicCompleteCommand.cs +++ b/Source/Cli/Commands/Completions/DynamicCompleteCommand.cs @@ -1,6 +1,7 @@ // Copyright (c) Cratis. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Reactive.Linq; using Cratis.Chronicle.Contracts.Jobs; using Cratis.Chronicle.Contracts.Observation.EventStoreSubscriptions; using Cratis.Cli.Commands.Chronicle; @@ -39,12 +40,12 @@ protected override async Task ExecuteCommandAsync(IServices services, Dynam break; case "jobs": - var jobs = await services.Jobs.GetJobs(new GetJobsRequest + var jobs = await services.Jobs.AllJobs(new AllJobsRequest { EventStore = eventStore, Namespace = ns }); - foreach (var job in jobs ?? []) + foreach (var job in jobs.Data ?? []) { Console.WriteLine(job.Id.ToString()); } @@ -78,8 +79,8 @@ protected override async Task ExecuteCommandAsync(IServices services, Dynam IEnumerable storeNames; if (eventStore == CliDefaults.DefaultEventStoreName) { - var allStores = await services.EventStores.GetEventStores(); - storeNames = allStores ?? []; + var allStores = await services.EventStores.AllEventStores(); + storeNames = allStores.Data ?? []; } else { @@ -105,8 +106,8 @@ protected override async Task ExecuteCommandAsync(IServices services, Dynam break; case "event-stores": - var stores = await services.EventStores.GetEventStores(); - foreach (var store in stores ?? []) + var stores = await services.EventStores.AllEventStores(); + foreach (var store in stores.Data ?? []) { Console.WriteLine(store); } @@ -139,8 +140,8 @@ protected override async Task ExecuteCommandAsync(IServices services, Dynam break; case "users": - var users = await services.Users.GetAll(); - foreach (var user in users ?? []) + var users = await services.Users.AllUsers().FirstAsync(); + foreach (var user in users.Data ?? []) { Console.WriteLine(user.Id); } @@ -148,8 +149,8 @@ protected override async Task ExecuteCommandAsync(IServices services, Dynam break; case "applications": - var apps = await services.Applications.GetAll(); - foreach (var app in apps ?? []) + var apps = await services.Applications.AllApplications().FirstAsync(); + foreach (var app in apps.Data ?? []) { Console.WriteLine(app.Id); }