Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/Speckle.Sdk/Api/GraphQL/Models/Workspace.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
using Speckle.Newtonsoft.Json;

namespace Speckle.Sdk.Api.GraphQL.Models;

public class LimitedWorkspace
{
public string id { get; init; }
public string name { get; init; }
public required string id { get; init; }
public required string name { get; init; }
public string? role { get; init; }
public string slug { get; init; }
public string? logo { get; init; }
public required string slug { get; init; }
public string? logoUri { get; init; }
public string? description { get; init; }

[JsonIgnore]
[Obsolete($"Deprecated, use {nameof(logoUri)} instead", true)]
public string? logo { get; init; }
}

public class Workspace : LimitedWorkspace
{
public DateTime createdAt { get; init; }
public DateTime updatedAt { get; init; }
public bool readOnly { get; init; }
public WorkspacePermissionChecks permissions { get; init; }
public required DateTime createdAt { get; init; }
public required DateTime updatedAt { get; init; }
public required bool readOnly { get; init; }
public required WorkspacePermissionChecks permissions { get; init; }

[JsonIgnore]
[Obsolete("Workspaces no longer have creation state, is always created true", true)]
public WorkspaceCreationState? creationState { get; init; }
}

[Obsolete("Workspaces no longer have creation state, is always created true")]
public sealed class WorkspaceCreationState
{
public bool completed { get; init; }
public required bool completed { get; init; }
}

public sealed class WorkspacePermissionChecks
{
public PermissionCheckResult canCreateProject { get; init; }
public required PermissionCheckResult canCreateProject { get; init; }
}
27 changes: 17 additions & 10 deletions src/Speckle.Sdk/Api/GraphQL/Resources/ActiveUserResource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GraphQL;
using GraphQL;
using Speckle.Sdk.Api.GraphQL.Inputs;
using Speckle.Sdk.Api.GraphQL.Models;
using Speckle.Sdk.Api.GraphQL.Models.Responses;
Expand Down Expand Up @@ -264,15 +264,11 @@ query ActiveUser($limit: Int!, $cursor: String, $filter: UserWorkspacesFilter) {
name
role
slug
logo
logoUrl
createdAt
updatedAt
readOnly
description
creationState
{
completed
}
permissions {
canCreateProject {
authorized
Expand Down Expand Up @@ -328,7 +324,7 @@ query ActiveUser {
name
role
slug
logo
logoUrl
description
}
}
Expand All @@ -337,9 +333,20 @@ query ActiveUser {

var request = new GraphQLRequest { Query = QUERY };

var response = await _client
.ExecuteGraphQLRequest<NullableResponse<NullableResponse<LimitedWorkspace?>?>>(request, cancellationToken)
.ConfigureAwait(false);
NullableResponse<NullableResponse<LimitedWorkspace?>?> response;
try
{
response = await _client
.ExecuteGraphQLRequest<NullableResponse<NullableResponse<LimitedWorkspace?>?>>(request, cancellationToken)
.ConfigureAwait(false);
}
catch (AggregateException a)
{
//v2.x.x servers do not have a logoUrl property
a.Handle(x => x is SpeckleGraphQLInvalidQueryException);

return null;
}

if (response.data is null)
{
Expand Down
7 changes: 7 additions & 0 deletions src/Speckle.Sdk/Api/GraphQL/Resources/CommentResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal CommentResource(ISpeckleGraphQLClient client)
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("Comments are deprecated in favour of Issues which we don't provide a .NET Resource for at this time")]
public async Task<Comment> Get(
string commentId,
string projectId,
Expand Down Expand Up @@ -99,6 +100,7 @@ query CommentThreads($projectId: String!, $commentId: String!, $repliesLimit: In
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("Comments are deprecated in favour of Issues which we don't provide a .NET Resource for at this time")]
public async Task<ProjectCommentCollection> GetProjectComments(
string projectId,
int limit = ServerLimits.DEFAULT_PAGINATION_REQUEST,
Expand Down Expand Up @@ -186,6 +188,7 @@ query CommentThreads($projectId: String!, $cursor: String, $limit: Int!, $filter
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("Comments are deprecated in favour of Issues which we don't provide a .NET Resource for at this time")]
internal async Task<Comment> Create(CreateCommentInput input, CancellationToken cancellationToken = default)
{
//language=graphql
Expand Down Expand Up @@ -227,6 +230,7 @@ mutation Mutation($input: CreateCommentInput!) {
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("Comments are deprecated in favour of Issues which we don't provide a .NET Resource for at this time")]
internal async Task<Comment> Edit(EditCommentInput input, CancellationToken cancellationToken = default)
{
//language=graphql
Expand Down Expand Up @@ -267,6 +271,7 @@ mutation Mutation($input: EditCommentInput!) {
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("Comments are deprecated in favour of Issues which we don't provide a .NET Resource for at this time")]
public async Task Archive(ArchiveCommentInput input, CancellationToken cancellationToken = default)
{
//language=graphql
Expand All @@ -293,6 +298,7 @@ mutation Mutation($input: ArchiveCommentInput!) {
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("Comments are deprecated in favour of Issues which we don't provide a .NET Resource for at this time")]
public async Task MarkViewed(MarkCommentViewedInput input, CancellationToken cancellationToken = default)
{
//language=graphql
Expand Down Expand Up @@ -320,6 +326,7 @@ mutation Mutation($input: MarkCommentViewedInput!) {
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("Comments are deprecated in favour of Issues which we don't provide a .NET Resource for at this time")]
internal async Task<Comment> Reply(CreateCommentReplyInput input, CancellationToken cancellationToken = default)
{
//language=graphql
Expand Down
37 changes: 19 additions & 18 deletions src/Speckle.Sdk/Api/GraphQL/Resources/OtherUserResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,34 @@ query LimitedUser($id: String!) {
/// <param name="query">String to search for. Must be at least 3 characters</param>
/// <param name="limit">Max number of users to fetch</param>
/// <param name="cursor">Optional cursor for pagination</param>
/// <param name="archived"></param>
/// <param name="emailOnly"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <inheritdoc cref="ISpeckleGraphQLClient.ExecuteGraphQLRequest{T}"/>
[Obsolete("User search is deprecated")]
public async Task<UserSearchResultCollection> UserSearch(
string query,
int limit = ServerLimits.DEFAULT_PAGINATION_REQUEST,
string? cursor = null,
bool archived = false,
bool emailOnly = false,
CancellationToken cancellationToken = default
)
{
//language=graphql
const string QUERY = """
query UserSearch($query: String!, $limit: Int!, $cursor: String, $archived: Boolean, $emailOnly: Boolean) {
data:userSearch(query: $query, limit: $limit, cursor: $cursor, archived: $archived, emailOnly: $emailOnly) {
query Users($input: UsersRetrievalInput!) {
data:users(input: $input) {
cursor
items {
id
name
bio
company
avatar
verified
role
}
}
id
name
bio
company
avatar
verified
role
}
}
}
""";

Expand All @@ -89,11 +88,13 @@ query UserSearch($query: String!, $limit: Int!, $cursor: String, $archived: Bool
Query = QUERY,
Variables = new
{
query,
limit,
cursor,
archived,
emailOnly,
input = new
{
query,
limit,
emailOnly,
cursor,
},
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ subscription UserProjectsUpdated {
/// <summary>Subscribe to updates to resource comments/threads. Optionally specify resource ID string to only receive updates regarding comments for those resources</summary>
/// <remarks><inheritdoc cref="CreateUserProjectsUpdatedSubscription"/></remarks>
/// <inheritdoc cref="ISpeckleGraphQLClient.SubscribeTo{T}"/>
[Obsolete("Comments are now issues, and we've not update SDKs with the new subs")]
public Subscription<ProjectCommentsUpdatedMessage> CreateProjectCommentsUpdatedSubscription(
ViewerUpdateTrackingTarget target
)
Expand Down
6 changes: 1 addition & 5 deletions src/Speckle.Sdk/Api/GraphQL/Resources/WorkspaceResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ query WorkspaceGet($workspaceId: String!) {
name
role
slug
logo
logoUrl
createdAt
updatedAt
readOnly
description
creationState
{
completed
}
permissions {
canCreateProject {
authorized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ await FluentActions
.ThrowAsync<SpeckleException>();
}

[Fact]
[Fact, Trait("Server", "Internal")]
public async Task ActiveUserGetWorkspaces()
{
var ex = await Assert.ThrowsAsync<AggregateException>(async () => _ = await Sut.GetWorkspaces());
await Verify(ex);
}

[Fact]
[Fact, Trait("Server", "Internal")]
public async Task ActiveUserGetWorkspaces_NoAuth()
{
await FluentActions
Expand All @@ -130,7 +130,7 @@ public async Task ActiveUserGetActiveWorkspace()
res.Should().Be(null);
}

[Fact]
[Fact, Trait("Server", "Internal")]
public async Task ActiveUserGetActiveWorkspace_NoAuth()
{
await FluentActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ private static async Task<IClient> Setup()
return testUser;
}

[Fact]
[Fact, Trait("Server", "Internal")]
public async Task TestGetWorkspace()
{
var ex = await Assert.ThrowsAsync<AggregateException>(async () => _ = await Sut.Get("non-existent-id"));
ex.InnerExceptions.Should().HaveCount(1);
ex.InnerExceptions.Should().AllBeOfType<SpeckleGraphQLForbiddenException>();
ex.InnerExceptions.Should().AllBeOfType<SpeckleGraphQLWorkspaceNotEnabledException>();
}

[Fact, Trait("Server", "Internal")]
public async Task TestGetProjectsInternal()
{
var ex = await Assert.ThrowsAsync<AggregateException>(async () => _ = await Sut.GetProjects("non-existent-id"));
ex.InnerExceptions.Should().HaveCount(1);
ex.InnerExceptions.Should().AllBeOfType<SpeckleGraphQLWorkspaceNotEnabledException>();
}

[Fact]
[Fact, Trait("Server", "Public")]
public async Task TestGetProjects()
{
var ex = await Assert.ThrowsAsync<AggregateException>(async () => _ = await Sut.GetProjects("non-existent-id"));
Expand Down