Small QOL tweaks to Version.Create and ProjectModelsFilter (#210)
* Version Create now returns a Version * ProjectModelsFilter now has optional args
This commit is contained in:
@@ -11,18 +11,12 @@ public sealed record ProjectInviteCreateInput(string? email, string? role, strin
|
||||
public sealed record ProjectInviteUseInput(bool accept, string projectId, string token);
|
||||
|
||||
public sealed record ProjectModelsFilter(
|
||||
IReadOnlyList<string>? contributors,
|
||||
IReadOnlyList<string>? excludeIds,
|
||||
IReadOnlyList<string>? ids,
|
||||
bool? onlyWithVersions,
|
||||
string? search,
|
||||
IReadOnlyList<string>? sourceApps
|
||||
);
|
||||
|
||||
public sealed record ProjectModelsTreeFilter(
|
||||
IReadOnlyList<string>? contributors,
|
||||
string? search,
|
||||
IReadOnlyList<string>? sourceApps
|
||||
IReadOnlyList<string>? contributors = null,
|
||||
IReadOnlyList<string>? excludeIds = null,
|
||||
IReadOnlyList<string>? ids = null,
|
||||
bool? onlyWithVersions = null,
|
||||
string? search = null,
|
||||
IReadOnlyList<string>? sourceApps = null
|
||||
);
|
||||
|
||||
public sealed record ProjectUpdateInput(
|
||||
|
||||
@@ -127,14 +127,28 @@ public sealed class VersionResource
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>id of the created <see cref="Version"/></returns>
|
||||
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
|
||||
public async Task<string> Create(CreateVersionInput input, CancellationToken cancellationToken = default)
|
||||
public async Task<Version> Create(CreateVersionInput input, CancellationToken cancellationToken = default)
|
||||
{
|
||||
//language=graphql
|
||||
const string QUERY = """
|
||||
mutation Create($input: CreateVersionInput!) {
|
||||
data:versionMutations {
|
||||
data:create(input: $input) {
|
||||
data:id
|
||||
id
|
||||
referencedObject
|
||||
message
|
||||
sourceApplication
|
||||
createdAt
|
||||
previewUrl
|
||||
authorUser {
|
||||
id
|
||||
name
|
||||
bio
|
||||
company
|
||||
verified
|
||||
role
|
||||
avatar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,9 +157,9 @@ public sealed class VersionResource
|
||||
GraphQLRequest request = new() { Query = QUERY, Variables = new { input } };
|
||||
|
||||
var response = await _client
|
||||
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<RequiredResponse<string>>>>(request, cancellationToken)
|
||||
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<Version>>>(request, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
return response.data.data.data;
|
||||
return response.data.data;
|
||||
}
|
||||
|
||||
/// <param name="input"></param>
|
||||
|
||||
@@ -5,6 +5,7 @@ using Speckle.Sdk.Api.GraphQL.Models;
|
||||
using Speckle.Sdk.Api.GraphQL.Resources;
|
||||
using Speckle.Sdk.Common;
|
||||
using Xunit;
|
||||
using Version = Speckle.Sdk.Api.GraphQL.Models.Version;
|
||||
|
||||
namespace Speckle.Sdk.Tests.Integration.API.GraphQL.Resources;
|
||||
|
||||
@@ -14,17 +15,17 @@ public class CommentResourceTests
|
||||
private readonly CommentResource Sut;
|
||||
private readonly Project _project;
|
||||
private readonly Model _model;
|
||||
private readonly string _versionId;
|
||||
private readonly Version _version;
|
||||
private readonly Comment _comment;
|
||||
|
||||
// Constructor for setup
|
||||
public CommentResourceTests()
|
||||
{
|
||||
// Synchronous operations converted to async Task.Run for constructor
|
||||
_testUser = Task.Run(async () => await Fixtures.SeedUserWithClient()).Result!;
|
||||
_project = Task.Run(async () => await _testUser.Project.Create(new("Test project", "", null))).Result!;
|
||||
_model = Task.Run(async () => await _testUser.Model.Create(new("Test Model 1", "", _project.id))).Result!;
|
||||
_versionId = Task.Run(async () => await Fixtures.CreateVersion(_testUser, _project.id, _model.id)).Result!;
|
||||
_testUser = Task.Run(async () => await Fixtures.SeedUserWithClient()).Result;
|
||||
_project = Task.Run(async () => await _testUser.Project.Create(new("Test project", "", null))).Result;
|
||||
_model = Task.Run(async () => await _testUser.Model.Create(new("Test Model 1", "", _project.id))).Result;
|
||||
_version = Task.Run(async () => await Fixtures.CreateVersion(_testUser, _project.id, _model.id)).Result;
|
||||
_comment = Task.Run(CreateComment).Result!;
|
||||
Sut = _testUser.Comment;
|
||||
}
|
||||
@@ -110,6 +111,6 @@ public class CommentResourceTests
|
||||
|
||||
private async Task<Comment> CreateComment()
|
||||
{
|
||||
return await Fixtures.CreateComment(_testUser, _project.id, _model.id, _versionId);
|
||||
return await Fixtures.CreateComment(_testUser, _project.id, _model.id, _version.id);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -5,6 +5,7 @@ using Speckle.Sdk.Api.GraphQL.Inputs;
|
||||
using Speckle.Sdk.Api.GraphQL.Models;
|
||||
using Speckle.Sdk.Api.GraphQL.Resources;
|
||||
using Xunit;
|
||||
using Version = Speckle.Sdk.Api.GraphQL.Models.Version;
|
||||
|
||||
namespace Speckle.Sdk.Tests.Integration.API.GraphQL.Resources;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class SubscriptionResourceTests : IAsyncLifetime
|
||||
private Client _testUser;
|
||||
private Project _testProject;
|
||||
private Model _testModel;
|
||||
private string _testVersion;
|
||||
private Version _testVersion;
|
||||
|
||||
private SubscriptionResource Sut => _testUser.Subscription;
|
||||
|
||||
@@ -109,7 +110,7 @@ public class SubscriptionResourceTests : IAsyncLifetime
|
||||
await Task.Delay(WAIT_PERIOD); // Give time for subscription to be triggered
|
||||
|
||||
subscriptionMessage.Should().NotBeNull();
|
||||
subscriptionMessage!.id.Should().Be(created);
|
||||
subscriptionMessage!.id.Should().Be(created.id);
|
||||
subscriptionMessage.type.Should().Be(ProjectVersionsUpdatedMessageType.CREATED);
|
||||
subscriptionMessage.version.Should().NotBeNull();
|
||||
}
|
||||
@@ -125,7 +126,7 @@ public class SubscriptionResourceTests : IAsyncLifetime
|
||||
|
||||
await Task.Delay(WAIT_PERIOD); // Give time to subscription to be setup
|
||||
|
||||
var created = await Fixtures.CreateComment(_testUser, _testProject.id, _testModel.id, _testVersion);
|
||||
var created = await Fixtures.CreateComment(_testUser, _testProject.id, _testModel.id, _testVersion.id);
|
||||
|
||||
await Task.Delay(WAIT_PERIOD); // Give time for subscription to be triggered
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ public class VersionResourceTests : IAsyncLifetime
|
||||
_model1 = await _testUser.Model.Create(new("Test Model 1", "", _project.id));
|
||||
_model2 = await _testUser.Model.Create(new("Test Model 2", "", _project.id));
|
||||
|
||||
string versionId = await Fixtures.CreateVersion(_testUser, _project.id, _model1.id);
|
||||
|
||||
_version = await Sut.Get(versionId, _project.id);
|
||||
_version = await Fixtures.CreateVersion(_testUser, _project.id, _model1.id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -13,6 +13,7 @@ using Speckle.Sdk.Host;
|
||||
using Speckle.Sdk.Models;
|
||||
using Speckle.Sdk.Tests.Unit.Serialisation;
|
||||
using Speckle.Sdk.Transports;
|
||||
using Version = Speckle.Sdk.Api.GraphQL.Models.Version;
|
||||
|
||||
namespace Speckle.Sdk.Tests.Integration;
|
||||
|
||||
@@ -39,7 +40,7 @@ public static class Fixtures
|
||||
return ServiceProvider.GetRequiredService<IClientFactory>().Create(await SeedUser());
|
||||
}
|
||||
|
||||
public static async Task<string> CreateVersion(Client client, string projectId, string modelId)
|
||||
public static async Task<Version> CreateVersion(Client client, string projectId, string modelId)
|
||||
{
|
||||
using var remote = ServiceProvider.GetRequiredService<IServerTransportFactory>().Create(client.Account, projectId);
|
||||
var (objectId, _) = await ServiceProvider
|
||||
|
||||
@@ -11,6 +11,7 @@ using Speckle.Sdk.Host;
|
||||
using Speckle.Sdk.Models;
|
||||
using Speckle.Sdk.Serialisation;
|
||||
using Speckle.Sdk.Transports;
|
||||
using Version = Speckle.Sdk.Api.GraphQL.Models.Version;
|
||||
|
||||
namespace Speckle.Sdk.Tests.Performance.Benchmarks;
|
||||
|
||||
@@ -62,7 +63,7 @@ public class GeneralSendTest
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
public async Task<string> Send_old()
|
||||
public async Task<Version> Send_old()
|
||||
{
|
||||
using SQLiteTransport local = new();
|
||||
var res = await _operations.Send(_testData, [_remote, local]);
|
||||
@@ -70,13 +71,13 @@ public class GeneralSendTest
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public async Task<string> Send_new()
|
||||
public async Task<Version> Send_new()
|
||||
{
|
||||
var res = await _operations.Send2(new(acc.serverInfo.url), _project.id, acc.token, _testData, null, default);
|
||||
return await TagVersion($"Send_new {Guid.NewGuid()}", res.RootId);
|
||||
}
|
||||
|
||||
private async Task<string> TagVersion(string name, string objectId)
|
||||
private async Task<Version> TagVersion(string name, string objectId)
|
||||
{
|
||||
var model = await client.Model.Create(new(name, null, _project.id));
|
||||
return await client.Version.Create(new(objectId, model.id, _project.id));
|
||||
|
||||
Reference in New Issue
Block a user