Merge remote-tracking branch 'origin/dev' into jedd/cnx-1114-add-support-for-vertex-normals

This commit is contained in:
Jedd Morgan
2025-02-13 10:56:17 +00:00
23 changed files with 95 additions and 27 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Sdk.Serialization.T
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Sdk.Dependencies", "src\Speckle.Sdk.Dependencies\Speckle.Sdk.Dependencies.csproj", "{27584AB4-8ACD-4850-8CC2-7E5BC739FB78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Sdk.Testing", "Speckle.Sdk.Testing\Speckle.Sdk.Testing.csproj", "{7B617C0D-2354-415C-993C-5071D4113E27}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Sdk.Testing", "tests\Speckle.Sdk.Testing\Speckle.Sdk.Testing.csproj", "{7B617C0D-2354-415C-993C-5071D4113E27}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "performance", "performance", "{FFB07238-87E8-463A-AA39-3B38AAAA94C1}"
EndProject
+32 -1
View File
@@ -1,4 +1,6 @@
namespace Speckle.Sdk.Api.GraphQL.Models;
using Speckle.Newtonsoft.Json;
namespace Speckle.Sdk.Api.GraphQL.Models;
public sealed class Comment
{
@@ -17,4 +19,33 @@ public sealed class Comment
public DateTime updatedAt { get; init; }
public DateTime? viewedAt { get; init; }
public List<ViewerResourceItem> viewerResources { get; init; }
public SerializedViewerState viewerState { get; init; }
}
/// <summary>
/// See <c>SerializedViewerState</c> in <a href="https://github.com/specklesystems/speckle-server/blob/main/packages/shared/src/viewer/helpers/state.ts">/shared/src/viewer/helpers/state.ts</a>
/// </summary>
/// <remarks>
/// Note, there are many FE/Viewer specific properties on this object that are not reflected here (hence the <see cref="MissingMemberHandling"/> override)
/// We can add them as needed, keeping in mind flexiblity for breaking changes (these classes are intentionally not documented in our schema!)
/// </remarks>
[JsonObject(MissingMemberHandling = MissingMemberHandling.Ignore)]
public sealed class SerializedViewerState
{
public ViewerStateUI ui { get; init; }
}
[JsonObject(MissingMemberHandling = MissingMemberHandling.Ignore)]
public sealed class ViewerStateUI
{
public ViewerStateCamera camera { get; init; }
}
[JsonObject(MissingMemberHandling = MissingMemberHandling.Ignore)]
public sealed class ViewerStateCamera
{
public List<double> position { get; init; }
public List<double> target { get; init; }
public bool isOrthoProjection { get; init; }
public double zoom { get; init; }
}
@@ -77,7 +77,8 @@ public sealed class ProjectVersionsUpdatedMessage : EventArgs
[JsonRequired]
public ProjectVersionsUpdatedMessageType type { get; init; }
public string? modelId { get; init; }
[JsonRequired]
public string modelId { get; init; }
public Version? version { get; init; }
}
@@ -150,6 +150,7 @@ public sealed class CommentResource
objectId
versionId
}
viewerState
}
}
}
@@ -12,7 +12,8 @@ public record DeserializeProcessOptions(
bool SkipCache = false,
bool ThrowOnMissingReferences = true,
bool SkipInvalidConverts = false,
int? MaxParallelism = null
int? MaxParallelism = null,
bool SkipServer = false
);
public partial interface IDeserializeProcess : IDisposable;
@@ -49,28 +49,33 @@ public sealed class ObjectLoader(
return (new(rootJson), allChildren);
}
}
rootJson = await serverObjectManager
.DownloadSingleObject(rootId, progress, cancellationToken)
.NotNull()
.ConfigureAwait(false);
IReadOnlyCollection<Id> allChildrenIds = ClosureParser
.GetClosures(rootJson, cancellationToken)
.OrderByDescending(x => x.Item2)
.Select(x => new Id(x.Item1))
.Where(x => !x.Value.StartsWith("blob", StringComparison.Ordinal))
.Freeze();
_allChildrenCount = allChildrenIds.Count;
await GetAndCache(allChildrenIds.Select(x => x.Value), cancellationToken, _options.MaxParallelism)
.ConfigureAwait(false);
CheckForExceptions();
cancellationToken.ThrowIfCancellationRequested();
//save the root last to shortcut later
if (!options.SkipCache)
if (!options.SkipServer)
{
sqLiteJsonCacheManager.SaveObject(rootId, rootJson);
rootJson = await serverObjectManager
.DownloadSingleObject(rootId, progress, cancellationToken)
.NotNull()
.ConfigureAwait(false);
IReadOnlyCollection<Id> allChildrenIds = ClosureParser
.GetClosures(rootJson, cancellationToken)
.OrderByDescending(x => x.Item2)
.Select(x => new Id(x.Item1))
.Where(x => !x.Value.StartsWith("blob", StringComparison.Ordinal))
.Freeze();
_allChildrenCount = allChildrenIds.Count;
await GetAndCache(allChildrenIds.Select(x => x.Value), cancellationToken, _options.MaxParallelism)
.ConfigureAwait(false);
CheckForExceptions();
cancellationToken.ThrowIfCancellationRequested();
//save the root last to shortcut later
if (!options.SkipCache)
{
sqLiteJsonCacheManager.SaveObject(rootId, rootJson);
}
return (new(rootJson), allChildrenIds);
}
return (new(rootJson), allChildrenIds);
throw new SpeckleException("Cannot skip server and cache. Please choose one.");
}
[AutoInterfaceIgnore]
@@ -15,7 +15,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Speckle.Objects\Speckle.Objects.csproj" />
<ProjectReference Include="..\..\Speckle.Sdk.Testing\Speckle.Sdk.Testing.csproj" />
<ProjectReference Include="..\Speckle.Sdk.Testing\Speckle.Sdk.Testing.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,5 @@
{
"Type": "Speckle.Sdk.SpeckleException",
"Message": "Cannot skip server and cache. Please choose one.",
"Source": "Speckle.Sdk"
}
@@ -60,6 +60,30 @@ public class ExceptionTests
await Verify(ex);
}
[Fact]
public async Task Test_Exceptions_Receive_Server_Skip_Both()
{
var o = new ObjectLoader(
new DummySqLiteReceiveManager(new Dictionary<string, string>()),
new ExceptionServerObjectManager(),
null
);
using var process = new DeserializeProcess(
null,
o,
new BaseDeserializer(new ObjectDeserializerFactory()),
new NullLoggerFactory(),
default,
new(SkipCache: true, MaxParallelism: 1, SkipServer: true)
);
var ex = await Assert.ThrowsAsync<SpeckleException>(async () =>
{
var root = await process.Deserialize(Guid.NewGuid().ToString());
});
await Verify(ex);
}
[Theory]
[InlineData("RevitObject.json.gz", "3416d3fe01c9196115514c4a2f41617b", 7818)]
public async Task Test_Exceptions_Receive_Server(string fileName, string rootId, int oldCount)
@@ -15,7 +15,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Speckle.Sdk.Testing\Speckle.Sdk.Testing.csproj" />
<ProjectReference Include="..\Speckle.Sdk.Testing\Speckle.Sdk.Testing.csproj" />
<ProjectReference Include="..\..\src\Speckle.Objects\Speckle.Objects.csproj" />
</ItemGroup>
@@ -13,7 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\Speckle.Sdk\Speckle.Sdk.csproj" />
<ProjectReference Include="..\..\src\Speckle.Sdk\Speckle.Sdk.csproj" />
</ItemGroup>
</Project>