Compare commits
9 Commits
3.3.0-dev.1
...
3.3.4
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d3985f93b | |||
| 915a18dc98 | |||
| 5fcb3223d6 | |||
| 21851c06d2 | |||
| 3a9a633d30 | |||
| 7f092d529c | |||
| a4f0e0e4aa | |||
| 227729a0df | |||
| 178085f3f8 |
@@ -26,3 +26,8 @@ public sealed class ProjectWithTeam : Project
|
|||||||
public List<PendingStreamCollaborator> invitedTeam { get; init; }
|
public List<PendingStreamCollaborator> invitedTeam { get; init; }
|
||||||
public List<ProjectCollaborator> team { get; init; }
|
public List<ProjectCollaborator> team { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class ProjectWithPermissions : Project
|
||||||
|
{
|
||||||
|
public ProjectPermissionChecks permissions { get; init; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,4 +4,6 @@ public sealed class ProjectPermissionChecks
|
|||||||
{
|
{
|
||||||
public PermissionCheckResult canCreateModel { get; init; }
|
public PermissionCheckResult canCreateModel { get; init; }
|
||||||
public PermissionCheckResult canDelete { get; init; }
|
public PermissionCheckResult canDelete { get; init; }
|
||||||
|
public PermissionCheckResult canLoad { get; init; }
|
||||||
|
public PermissionCheckResult canPublish { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ public sealed class Workspace
|
|||||||
public string role { get; init; }
|
public string role { get; init; }
|
||||||
public string slug { get; init; }
|
public string slug { get; init; }
|
||||||
public string? description { get; init; }
|
public string? description { get; init; }
|
||||||
|
public string? logo { get; init; }
|
||||||
|
public DateTime? createdAt { get; init; }
|
||||||
|
public DateTime? updatedAt { get; init; }
|
||||||
|
public bool? readOnly { get; init; }
|
||||||
public WorkspacePermissionChecks permissions { get; init; }
|
public WorkspacePermissionChecks permissions { get; init; }
|
||||||
public WorkspaceCreationState? creationState { get; init; }
|
public WorkspaceCreationState? creationState { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,4 +361,89 @@ public sealed class ActiveUserResource
|
|||||||
|
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <param name="limit">Max number of projects to fetch</param>
|
||||||
|
/// <param name="cursor">Optional cursor for pagination</param>
|
||||||
|
/// <param name="filter">Optional filter</param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
|
||||||
|
/// <exception cref="SpeckleException">The ActiveUser could not be found (e.g. the client is not authenticated)</exception>
|
||||||
|
public async Task<ResourceCollection<ProjectWithPermissions>> GetProjectsWithPermissions(
|
||||||
|
int limit = ServerLimits.DEFAULT_PAGINATION_REQUEST,
|
||||||
|
string? cursor = null,
|
||||||
|
UserProjectsFilter? filter = null,
|
||||||
|
CancellationToken cancellationToken = default
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//language=graphql
|
||||||
|
const string QUERY = """
|
||||||
|
query User($limit: Int!, $cursor: String, $filter: UserProjectsFilter) {
|
||||||
|
data: activeUser {
|
||||||
|
data: projects(limit: $limit, cursor: $cursor, filter: $filter) {
|
||||||
|
totalCount
|
||||||
|
cursor
|
||||||
|
items {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
description
|
||||||
|
visibility
|
||||||
|
allowPublicComments
|
||||||
|
role
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
sourceApps
|
||||||
|
workspaceId
|
||||||
|
permissions {
|
||||||
|
canCreateModel {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canDelete {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canLoad {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canPublish {
|
||||||
|
code
|
||||||
|
authorized
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
var request = new GraphQLRequest
|
||||||
|
{
|
||||||
|
Query = QUERY,
|
||||||
|
Variables = new
|
||||||
|
{
|
||||||
|
limit,
|
||||||
|
cursor,
|
||||||
|
filter,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = await _client
|
||||||
|
.ExecuteGraphQLRequest<NullableResponse<RequiredResponse<ResourceCollection<ProjectWithPermissions>>?>>(
|
||||||
|
request,
|
||||||
|
cancellationToken
|
||||||
|
)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (response.data is null)
|
||||||
|
{
|
||||||
|
throw new SpeckleException("GraphQL response indicated that the ActiveUser could not be found");
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.data.data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,16 @@ public sealed class ProjectResource
|
|||||||
code
|
code
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
canLoad {
|
||||||
|
authorized
|
||||||
|
code
|
||||||
|
message
|
||||||
|
}
|
||||||
|
canPublish {
|
||||||
|
authorized
|
||||||
|
code
|
||||||
|
message
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ public sealed class WorkspaceResource
|
|||||||
var request = new GraphQLRequest { Query = QUERY, Variables = new { workspaceId } };
|
var request = new GraphQLRequest { Query = QUERY, Variables = new { workspaceId } };
|
||||||
|
|
||||||
var response = await _client
|
var response = await _client
|
||||||
.ExecuteGraphQLRequest<RequiredResponse<RequiredResponse<Workspace>>>(request, cancellationToken)
|
.ExecuteGraphQLRequest<RequiredResponse<Workspace>>(request, cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return response.data.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <param name="workspaceId"></param>
|
/// <param name="workspaceId"></param>
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ public sealed class SerializeProcess(
|
|||||||
NodeInfo
|
NodeInfo
|
||||||
>();
|
>();
|
||||||
|
|
||||||
|
private readonly Pool<List<Task<Dictionary<Id, NodeInfo>>>> _taskResultPool = Pools.CreateListPool<
|
||||||
|
Task<Dictionary<Id, NodeInfo>>
|
||||||
|
>();
|
||||||
|
|
||||||
private long _objectCount;
|
private long _objectCount;
|
||||||
private long _objectsFound;
|
private long _objectsFound;
|
||||||
|
|
||||||
@@ -163,7 +167,7 @@ public sealed class SerializeProcess(
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tasks = new List<Task<Dictionary<Id, NodeInfo>>>();
|
var tasks = _taskResultPool.Get();
|
||||||
foreach (var child in baseChildFinder.GetChildren(obj))
|
foreach (var child in baseChildFinder.GetChildren(obj))
|
||||||
{
|
{
|
||||||
// tmp is necessary because of the way closures close over loop variables
|
// tmp is necessary because of the way closures close over loop variables
|
||||||
@@ -190,30 +194,27 @@ public sealed class SerializeProcess(
|
|||||||
return EMPTY_CLOSURES;
|
return EMPTY_CLOSURES;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Dictionary<Id, NodeInfo>> taskClosures = new();
|
Dictionary<Id, NodeInfo>[] taskClosures = [];
|
||||||
if (tasks.Count > 0)
|
if (tasks.Count > 0)
|
||||||
{
|
{
|
||||||
var currentTasks = tasks.ToList();
|
//get child results
|
||||||
do
|
var childTask = Task.WhenAll(tasks);
|
||||||
|
await Task.WhenAny(childTask, Task.Delay(Timeout.InfiniteTimeSpan, _processSource.Token)).ConfigureAwait(false);
|
||||||
|
if (childTask.IsFaulted)
|
||||||
{
|
{
|
||||||
//grab when any Task is done and see if we're cancelling
|
if (childTask.Exception is not null)
|
||||||
var t = await Task.WhenAny(currentTasks).ConfigureAwait(false);
|
|
||||||
if (t.IsCanceled)
|
|
||||||
{
|
{
|
||||||
return EMPTY_CLOSURES;
|
RecordException(childTask.Exception);
|
||||||
}
|
}
|
||||||
if (t.IsFaulted)
|
return EMPTY_CLOSURES;
|
||||||
{
|
}
|
||||||
if (t.Exception is not null)
|
if (!childTask.IsCompleted)
|
||||||
{
|
{
|
||||||
RecordException(t.Exception);
|
return EMPTY_CLOSURES;
|
||||||
}
|
}
|
||||||
return EMPTY_CLOSURES;
|
taskClosures = childTask.Result;
|
||||||
}
|
|
||||||
taskClosures.Add(t.Result);
|
|
||||||
currentTasks.Remove(t);
|
|
||||||
} while (currentTasks.Count > 0);
|
|
||||||
}
|
}
|
||||||
|
_taskResultPool.Return(tasks);
|
||||||
|
|
||||||
if (_processSource.Token.IsCancellationRequested)
|
if (_processSource.Token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"id": "15168a13ce3f336dee9aa1807cbf375c",
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject:Objects.Data.ArcgisObject",
|
||||||
|
"type": null,
|
||||||
|
"units": null
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"elements": null,
|
||||||
|
"id": "bf80e8a10eca2264f11c39bae42538da",
|
||||||
|
"level": null,
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject:Objects.Data.ArchicadObject",
|
||||||
|
"type": null
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"baseCurves": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"elements": null,
|
||||||
|
"id": "76b7634117981a9fb9d3cffca5464f26",
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject:Objects.Data.Civil3dObject",
|
||||||
|
"type": null,
|
||||||
|
"units": null
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"id": "a1567a1cf10417294c93b70bf5ca97c1",
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject"
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"elements": null,
|
||||||
|
"id": "39d4deaa7cd20e7004812304f41a68d5",
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject:Objects.Data.EtabsObject",
|
||||||
|
"type": null,
|
||||||
|
"units": null
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"id": "fbda4ea7bb1b3722ca28e97573742a4e",
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject:Objects.Data.NavisworksObject",
|
||||||
|
"units": null
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"category": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"elements": null,
|
||||||
|
"family": null,
|
||||||
|
"id": "7e285508a71c55589bbc053451f687d2",
|
||||||
|
"level": null,
|
||||||
|
"location": null,
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject:Objects.Data.RevitObject",
|
||||||
|
"type": null,
|
||||||
|
"units": null
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"applicationId": null,
|
||||||
|
"displayValue": null,
|
||||||
|
"elements": null,
|
||||||
|
"id": "c07f15678d8b4a48a7ecab9eb30e69a8",
|
||||||
|
"name": null,
|
||||||
|
"properties": null,
|
||||||
|
"speckle_type": "Objects.Data.DataObject:Objects.Data.TeklaObject",
|
||||||
|
"type": null,
|
||||||
|
"units": null
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections.Concurrent;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Speckle.Objects.Data;
|
||||||
|
using Speckle.Objects.Geometry;
|
||||||
|
using Speckle.Sdk.Models;
|
||||||
|
using Speckle.Sdk.Serialisation;
|
||||||
|
using Speckle.Sdk.Serialisation.V2;
|
||||||
|
using Speckle.Sdk.Serialisation.V2.Send;
|
||||||
|
|
||||||
|
namespace Speckle.Sdk.Serialization.Tests;
|
||||||
|
|
||||||
|
public class DataObjectTests
|
||||||
|
{
|
||||||
|
private readonly ISerializeProcessFactory _factory;
|
||||||
|
|
||||||
|
public DataObjectTests()
|
||||||
|
{
|
||||||
|
var serviceCollection = new ServiceCollection();
|
||||||
|
serviceCollection.AddSpeckleSdk(new("Tests", "test"), "v3", typeof(TestClass).Assembly, typeof(Polyline).Assembly);
|
||||||
|
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||||
|
|
||||||
|
_factory = serviceProvider.GetRequiredService<ISerializeProcessFactory>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData(typeof(ArcgisObject))]
|
||||||
|
[InlineData(typeof(ArchicadObject))]
|
||||||
|
[InlineData(typeof(Civil3dObject))]
|
||||||
|
[InlineData(typeof(DataObject))]
|
||||||
|
[InlineData(typeof(EtabsObject))]
|
||||||
|
[InlineData(typeof(NavisworksObject))]
|
||||||
|
[InlineData(typeof(RevitObject))]
|
||||||
|
[InlineData(typeof(TeklaObject))]
|
||||||
|
public async Task ValidateDataObject(Type type)
|
||||||
|
{
|
||||||
|
Base x = (Base)(Activator.CreateInstance(type) ?? throw new Exception("Could not create instance of " + type.Name));
|
||||||
|
|
||||||
|
var json = new ConcurrentDictionary<Id, Json>();
|
||||||
|
await using var serializeProcess = _factory.CreateSerializeProcess(
|
||||||
|
new MemoryJsonCacheManager(json),
|
||||||
|
new DummyServerObjectManager(),
|
||||||
|
null,
|
||||||
|
default,
|
||||||
|
new SerializeProcessOptions(true, true, false, true)
|
||||||
|
);
|
||||||
|
await serializeProcess.Serialize(x);
|
||||||
|
await VerifyJson(json.Single().Value.Value).UseParameters(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,6 +66,19 @@ public class ActiveUserResourceTests : IAsyncLifetime
|
|||||||
res.items.Count.Should().Be(2);
|
res.items.Count.Should().Be(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ActiveUserGetProjectsWithPermissions()
|
||||||
|
{
|
||||||
|
var p1 = await _testUser.Project.Create(new("Project 3", null, null));
|
||||||
|
var p2 = await _testUser.Project.Create(new("Project 4", null, null));
|
||||||
|
|
||||||
|
var res = await Sut.GetProjectsWithPermissions();
|
||||||
|
|
||||||
|
res.items.Should().Contain(x => x.id == p1.id);
|
||||||
|
res.items.Should().Contain(x => x.id == p2.id);
|
||||||
|
res.items.Count.Should().Be(2);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ActiveUserGetProjects_NoAuth()
|
public async Task ActiveUserGetProjects_NoAuth()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user