[FA-55] Finished aside from deactivation/integration events

This commit is contained in:
gamer147
2025-12-29 14:09:41 -05:00
parent c0290cc5af
commit 01d3b94050
19 changed files with 377 additions and 75 deletions

View File

@@ -6,6 +6,7 @@ using Microsoft.IdentityModel.Tokens;
using FictionArchive.Service.Shared.Constants;
using FictionArchive.Service.Shared.Models.Authentication;
using System.Linq;
using System.Security.Claims;
namespace FictionArchive.Service.Shared.Extensions;
@@ -78,7 +79,7 @@ public static class AuthenticationExtensions
logger.LogDebug(
"JWT token validated for subject: {Subject}",
context.Principal?.FindFirst("sub")?.Value ?? "unknown");
context.Principal?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? "unknown");
return existingEvents?.OnTokenValidated?.Invoke(context) ?? Task.CompletedTask;
}

View File

@@ -22,6 +22,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>

View File

@@ -17,7 +17,7 @@ public class Mutation
ClaimsPrincipal claimsPrincipal)
{
// Get the current user's OAuth provider ID from claims
var oAuthProviderId = claimsPrincipal.FindFirst("sub")?.Value;
var oAuthProviderId = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (string.IsNullOrEmpty(oAuthProviderId))
{
throw new InvalidOperationException("Unable to determine current user identity");

View File

@@ -2,53 +2,42 @@ using System.Security.Claims;
using FictionArchive.Service.UserService.Models.DTOs;
using FictionArchive.Service.UserService.Services;
using HotChocolate.Authorization;
using HotChocolate.Data;
namespace FictionArchive.Service.UserService.GraphQL;
public class Query
{
[Authorize]
public async Task<int> GetAvailableInvites(
UserManagementService userManagementService,
[UseProjection]
[UseFirstOrDefault]
public IQueryable<UserDto> GetCurrentUser(
UserServiceDbContext dbContext,
ClaimsPrincipal claimsPrincipal)
{
var oAuthProviderId = claimsPrincipal.FindFirst("sub")?.Value;
var oAuthProviderId = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (string.IsNullOrEmpty(oAuthProviderId))
{
return 0;
return Enumerable.Empty<UserDto>().AsQueryable();
}
var user = await userManagementService.GetUserByOAuthProviderIdAsync(oAuthProviderId);
return user?.AvailableInvites ?? 0;
}
[Authorize]
public async Task<UserDto?> GetCurrentUser(
UserManagementService userManagementService,
ClaimsPrincipal claimsPrincipal)
return dbContext.Users
.Where(u => u.OAuthProviderId == oAuthProviderId)
.Select(u => new UserDto
{
var oAuthProviderId = claimsPrincipal.FindFirst("sub")?.Value;
if (string.IsNullOrEmpty(oAuthProviderId))
Id = u.Id,
CreatedTime = u.CreatedTime,
LastUpdatedTime = u.LastUpdatedTime,
Username = u.Username,
Email = u.Email,
Disabled = u.Disabled,
AvailableInvites = u.AvailableInvites,
InviterId = u.InviterId,
InvitedUsers = u.InvitedUsers.Select(iu => new InvitedUserDto
{
return null;
}
var user = await userManagementService.GetUserByOAuthProviderIdAsync(oAuthProviderId);
if (user == null)
{
return null;
}
return new UserDto
{
Id = user.Id,
CreatedTime = user.CreatedTime,
LastUpdatedTime = user.LastUpdatedTime,
Username = user.Username,
Email = user.Email,
Disabled = user.Disabled,
AvailableInvites = user.AvailableInvites,
InviterId = user.InviterId
};
Username = iu.Username,
Email = iu.Email
}).ToList()
});
}
}

View File

@@ -0,0 +1,7 @@
namespace FictionArchive.Service.UserService.Models.DTOs;
public class InvitedUserDto
{
public required string Username { get; init; }
public required string Email { get; init; }
}

View File

@@ -13,4 +13,5 @@ public class UserDto
public bool Disabled { get; init; }
public int AvailableInvites { get; init; }
public Guid? InviterId { get; init; }
public List<InvitedUserDto>? InvitedUsers { get; init; }
}

View File

@@ -15,4 +15,5 @@ public class User : BaseEntity<Guid>
// Navigation properties
public Guid? InviterId { get; set; }
public User? Inviter { get; set; }
public ICollection<User> InvitedUsers { get; set; } = new List<User>();
}

View File

@@ -1,21 +1,21 @@
using System.Text.Json.Serialization;
using Newtonsoft.Json;
namespace FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
public class AuthentikAddUserRequest
{
[JsonPropertyName("username")]
[JsonProperty("username")]
public required string Username { get; set; }
[JsonPropertyName("name")]
[JsonProperty("name")]
public required string DisplayName { get; set; }
[JsonPropertyName("email")]
[JsonProperty("email")]
public required string Email { get; set; }
[JsonPropertyName("is_active")]
[JsonProperty("is_active")]
public bool IsActive { get; set; } = true;
[JsonPropertyName("type")]
[JsonProperty("type")]
public string Type { get; } = "external";
}

View File

@@ -1,4 +1,6 @@
using System.Net.Http.Json;
using System.Text;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
namespace FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
@@ -6,11 +8,16 @@ public class AuthentikClient : IAuthenticationServiceClient
{
private readonly HttpClient _httpClient;
private readonly ILogger<AuthentikClient> _logger;
private readonly AuthentikConfiguration _configuration;
public AuthentikClient(HttpClient httpClient, ILogger<AuthentikClient> logger)
public AuthentikClient(
HttpClient httpClient,
ILogger<AuthentikClient> logger,
IOptions<AuthentikConfiguration> configuration)
{
_httpClient = httpClient;
_logger = logger;
_configuration = configuration.Value;
}
public async Task<AuthentikUserResponse?> CreateUserAsync(string username, string email, string displayName)
@@ -25,7 +32,9 @@ public class AuthentikClient : IAuthenticationServiceClient
try
{
var response = await _httpClient.PostAsJsonAsync("/api/v3/core/users/", request);
var json = JsonConvert.SerializeObject(request);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync("/api/v3/core/users/", content);
if (!response.IsSuccessStatusCode)
{
@@ -36,7 +45,8 @@ public class AuthentikClient : IAuthenticationServiceClient
return null;
}
var userResponse = await response.Content.ReadFromJsonAsync<AuthentikUserResponse>();
var responseJson = await response.Content.ReadAsStringAsync();
var userResponse = JsonConvert.DeserializeObject<AuthentikUserResponse>(responseJson);
_logger.LogInformation("Successfully created user {Username} in Authentik with pk {Pk}",
username, userResponse?.Pk);
@@ -54,7 +64,7 @@ public class AuthentikClient : IAuthenticationServiceClient
try
{
var response = await _httpClient.PostAsync(
$"/api/v3/core/users/{authentikUserId}/recovery_email/",
$"/api/v3/core/users/{authentikUserId}/recovery_email/?email_stage={_configuration.EmailStageId}",
null);
if (!response.IsSuccessStatusCode)

View File

@@ -4,4 +4,5 @@ public class AuthentikConfiguration
{
public string BaseUrl { get; set; } = string.Empty;
public string ApiToken { get; set; } = string.Empty;
public string EmailStageId { get; set; }
}

View File

@@ -1,27 +1,27 @@
using System.Text.Json.Serialization;
using Newtonsoft.Json;
namespace FictionArchive.Service.UserService.Services.AuthenticationClient.Authentik;
public class AuthentikUserResponse
{
[JsonPropertyName("pk")]
[JsonProperty("pk")]
public int Pk { get; set; }
[JsonPropertyName("username")]
[JsonProperty("username")]
public string Username { get; set; } = string.Empty;
[JsonPropertyName("name")]
[JsonProperty("name")]
public string Name { get; set; } = string.Empty;
[JsonPropertyName("email")]
[JsonProperty("email")]
public string Email { get; set; } = string.Empty;
[JsonPropertyName("is_active")]
[JsonProperty("is_active")]
public bool IsActive { get; set; }
[JsonPropertyName("is_superuser")]
[JsonProperty("is_superuser")]
public bool IsSuperuser { get; set; }
[JsonPropertyName("uid")]
[JsonProperty("uid")]
public string Uid { get; set; } = string.Empty;
}

View File

@@ -118,4 +118,18 @@ public class UserManagementService
{
return _dbContext.Users.AsQueryable();
}
/// <summary>
/// Gets all users invited by a specific user.
/// </summary>
/// <param name="inviterId">The ID of the user who sent the invites</param>
/// <returns>List of users invited by the specified user</returns>
public async Task<List<User>> GetInvitedByUserAsync(Guid inviterId)
{
return await _dbContext.Users
.AsQueryable()
.Where(u => u.InviterId == inviterId)
.OrderByDescending(u => u.CreatedTime)
.ToListAsync();
}
}

View File

@@ -14,7 +14,8 @@
},
"Authentik": {
"BaseUrl": "https://auth.orfl.xyz",
"ApiToken": "REPLACE_ME"
"ApiToken": "REPLACE_ME",
"EmailStageId": "10df0c18-8802-4ec7-852e-3cdd355514d3"
},
"AllowedHosts": "*",
"OIDC": {

View File

@@ -44,6 +44,12 @@
<div
class="absolute right-0 z-50 mt-2 w-48 rounded-md bg-white p-2 shadow-lg dark:bg-gray-800"
>
<a
href="/settings"
class="flex w-full items-center justify-start rounded-md px-4 py-2 text-sm font-medium hover:bg-gray-100 dark:hover:bg-gray-700"
>
Settings
</a>
<Button variant="ghost" class="w-full justify-start" onclick={handleLogout}>
Sign out
</Button>

View File

@@ -0,0 +1,211 @@
<script lang="ts">
import { onMount } from 'svelte';
import { client } from '$lib/graphql/client';
import {
GetSettingsPageDataDocument,
InviteUserDocument,
type GetSettingsPageDataQuery
} from '$lib/graphql/__generated__/graphql';
import * as Tabs from '$lib/components/ui/tabs';
import { Button } from '$lib/components/ui/button';
import { Input } from '$lib/components/ui/input';
import { Card, CardContent, CardHeader, CardTitle } from '$lib/components/ui/card';
import { Badge } from '$lib/components/ui/badge';
let currentUser: GetSettingsPageDataQuery['currentUser'] | null = $state(null);
let fetching = $state(true);
let error: string | null = $state(null);
// Form state
let email = $state('');
let username = $state('');
let submitting = $state(false);
let formError: string | null = $state(null);
let formSuccess = $state(false);
const availableInvites = $derived(currentUser?.availableInvites ?? 0);
const canInvite = $derived(availableInvites > 0 && !submitting && !formSuccess);
async function fetchData() {
fetching = true;
error = null;
try {
const result = await client.query(GetSettingsPageDataDocument, {}).toPromise();
if (result.error) {
error = result.error.message;
return;
}
if (result.data) {
currentUser = result.data.currentUser;
}
} catch (e) {
error = e instanceof Error ? e.message : 'Unknown error';
} finally {
fetching = false;
}
}
async function handleInvite(e: Event) {
e.preventDefault();
if (!email.trim() || !username.trim()) {
formError = 'Please fill in all fields';
return;
}
submitting = true;
formError = null;
try {
const result = await client
.mutation(InviteUserDocument, {
input: { email: email.trim(), username: username.trim() }
})
.toPromise();
if (result.error) {
formError = result.error.message;
return;
}
if (result.data?.inviteUser?.errors?.length) {
formError = result.data.inviteUser.errors[0].message;
return;
}
if (result.data?.inviteUser?.userDto) {
formSuccess = true;
// Refresh data to update invite count and list
await fetchData();
// Reset form after delay
setTimeout(() => {
email = '';
username = '';
formSuccess = false;
}, 2000);
}
} catch (e) {
formError = e instanceof Error ? e.message : 'Unknown error occurred';
} finally {
submitting = false;
}
}
onMount(() => {
fetchData();
});
</script>
<div class="space-y-6">
<div>
<h1 class="text-3xl font-bold">Settings</h1>
<p class="text-muted-foreground">Manage your account settings</p>
</div>
{#if fetching}
<div class="flex items-center justify-center py-12">
<div class="text-muted-foreground">Loading...</div>
</div>
{:else if error}
<Card>
<CardContent class="py-6">
<p class="text-destructive">{error}</p>
<Button class="mt-4" onclick={fetchData}>Try Again</Button>
</CardContent>
</Card>
{:else}
<Tabs.Root value="invites">
<Tabs.List class="mb-6">
<Tabs.Trigger value="invites">Invites</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="invites" class="space-y-6">
<!-- Invite Form -->
<Card>
<CardHeader>
<CardTitle class="flex items-center gap-3">
Invite a User
<Badge variant={availableInvites > 0 ? 'default' : 'secondary'}>
{availableInvites} remaining
</Badge>
</CardTitle>
</CardHeader>
<CardContent>
<form onsubmit={handleInvite} class="space-y-4">
<div class="grid gap-4 sm:grid-cols-2">
<div class="space-y-2">
<label for="invite-email" class="text-sm font-medium">Email</label>
<Input
id="invite-email"
type="email"
placeholder="user@example.com"
bind:value={email}
disabled={!canInvite}
/>
</div>
<div class="space-y-2">
<label for="invite-username" class="text-sm font-medium">Username</label>
<Input
id="invite-username"
type="text"
placeholder="username"
bind:value={username}
disabled={!canInvite}
/>
</div>
</div>
{#if formError}
<p class="text-destructive text-sm">{formError}</p>
{/if}
{#if formSuccess}
<p class="text-green-600 dark:text-green-400 text-sm">
Invitation sent successfully! The user will receive an email to set up their account.
</p>
{/if}
<Button type="submit" disabled={!canInvite || !email.trim() || !username.trim()}>
{#if submitting}
Sending...
{:else if formSuccess}
Sent!
{:else}
Send Invite
{/if}
</Button>
</form>
</CardContent>
</Card>
<!-- Invited Users List -->
<Card>
<CardHeader>
<CardTitle>Invited Users</CardTitle>
</CardHeader>
<CardContent>
{#if !currentUser?.invitedUsers?.length}
<p class="text-muted-foreground text-sm">
You haven't invited anyone yet.
</p>
{:else}
<div class="divide-y">
{#each currentUser.invitedUsers as user}
<div class="flex items-center justify-between py-3 first:pt-0 last:pb-0">
<div>
<p class="font-medium">{user.username}</p>
<p class="text-muted-foreground text-sm">{user.email}</p>
</div>
</div>
{/each}
</div>
{/if}
</CardContent>
</Card>
</Tabs.Content>
</Tabs.Root>
{/if}
</div>

View File

@@ -156,6 +156,27 @@ export type InstantFilterInput = {
or?: InputMaybe<Array<InstantFilterInput>>;
};
export type InvalidOperationError = Error & {
message: Scalars['String']['output'];
};
export type InviteUserError = InvalidOperationError;
export type InviteUserInput = {
email: Scalars['String']['input'];
username: Scalars['String']['input'];
};
export type InviteUserPayload = {
errors: Maybe<Array<InviteUserError>>;
userDto: Maybe<UserDto>;
};
export type InvitedUserDto = {
email: Scalars['String']['output'];
username: Scalars['String']['output'];
};
export type JobKey = {
group: Scalars['String']['output'];
name: Scalars['String']['output'];
@@ -215,7 +236,7 @@ export type Mutation = {
deleteNovel: DeleteNovelPayload;
fetchChapterContents: FetchChapterContentsPayload;
importNovel: ImportNovelPayload;
registerUser: RegisterUserPayload;
inviteUser: InviteUserPayload;
runJob: RunJobPayload;
scheduleEventJob: ScheduleEventJobPayload;
translateText: TranslateTextPayload;
@@ -242,8 +263,8 @@ export type MutationImportNovelArgs = {
};
export type MutationRegisterUserArgs = {
input: RegisterUserInput;
export type MutationInviteUserArgs = {
input: InviteUserInput;
};
@@ -422,11 +443,11 @@ export type PersonDtoSortInput = {
export type Query = {
chapter: Maybe<ChapterReaderDto>;
currentUser: Array<UserDto>;
jobs: Array<SchedulerJob>;
novels: Maybe<NovelsConnection>;
translationEngines: Array<TranslationEngineDescriptor>;
translationRequests: Maybe<TranslationRequestsConnection>;
users: Array<UserDto>;
};
@@ -463,17 +484,6 @@ export type QueryTranslationRequestsArgs = {
where?: InputMaybe<TranslationRequestDtoFilterInput>;
};
export type RegisterUserInput = {
email: Scalars['String']['input'];
inviterOAuthProviderId?: InputMaybe<Scalars['String']['input']>;
oAuthProviderId: Scalars['String']['input'];
username: Scalars['String']['input'];
};
export type RegisterUserPayload = {
userDto: Maybe<UserDto>;
};
export type RunJobError = JobPersistenceError;
export type RunJobInput = {
@@ -700,11 +710,13 @@ export type UnsignedIntOperationFilterInputType = {
};
export type UserDto = {
availableInvites: Scalars['Int']['output'];
createdTime: Scalars['Instant']['output'];
disabled: Scalars['Boolean']['output'];
email: Scalars['String']['output'];
id: Scalars['UUID']['output'];
inviter: Maybe<UserDto>;
invitedUsers: Maybe<Array<InvitedUserDto>>;
inviterId: Maybe<Scalars['UUID']['output']>;
lastUpdatedTime: Scalars['Instant']['output'];
username: Scalars['String']['output'];
};
@@ -738,6 +750,13 @@ export type ImportNovelMutationVariables = Exact<{
export type ImportNovelMutation = { importNovel: { novelUpdateRequestedEvent: { novelUrl: string } | null } };
export type InviteUserMutationVariables = Exact<{
input: InviteUserInput;
}>;
export type InviteUserMutation = { inviteUser: { userDto: { id: any, username: string, email: string } | null, errors: Array<{ message: string }> | null } };
export type GetChapterQueryVariables = Exact<{
novelId: Scalars['UnsignedInt']['input'];
chapterOrder: Scalars['UnsignedInt']['input'];
@@ -763,9 +782,16 @@ export type NovelsQueryVariables = Exact<{
export type NovelsQuery = { novels: { edges: Array<{ cursor: string, node: { id: any, url: string, name: string, description: string, rawStatus: NovelStatus, lastUpdatedTime: any, coverImage: { newPath: string | null } | null, chapters: Array<{ order: any, name: string }>, tags: Array<{ key: string, displayName: string, tagType: TagType }> } }> | null, pageInfo: { hasNextPage: boolean, endCursor: string | null } } | null };
export type GetSettingsPageDataQueryVariables = Exact<{ [key: string]: never; }>;
export type GetSettingsPageDataQuery = { currentUser: Array<{ id: any, username: string, availableInvites: number, invitedUsers: Array<{ username: string, email: string }> | null }> };
export const DeleteNovelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteNovel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteNovelInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteNovel"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"boolean"}},{"kind":"Field","name":{"kind":"Name","value":"errors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Error"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]}}]}}]} as unknown as DocumentNode<DeleteNovelMutation, DeleteNovelMutationVariables>;
export const ImportNovelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ImportNovel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ImportNovelInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"importNovel"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novelUpdateRequestedEvent"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novelUrl"}}]}}]}}]}}]} as unknown as DocumentNode<ImportNovelMutation, ImportNovelMutationVariables>;
export const InviteUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"InviteUser"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"InviteUserInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"inviteUser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userDto"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"username"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}},{"kind":"Field","name":{"kind":"Name","value":"errors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"InvalidOperationError"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]}}]}}]} as unknown as DocumentNode<InviteUserMutation, InviteUserMutationVariables>;
export const GetChapterDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetChapter"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"novelId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UnsignedInt"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chapterOrder"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UnsignedInt"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"chapter"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"novelId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"novelId"}}},{"kind":"Argument","name":{"kind":"Name","value":"chapterOrder"},"value":{"kind":"Variable","name":{"kind":"Name","value":"chapterOrder"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"order"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"revision"}},{"kind":"Field","name":{"kind":"Name","value":"createdTime"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"images"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"novelId"}},{"kind":"Field","name":{"kind":"Name","value":"novelName"}},{"kind":"Field","name":{"kind":"Name","value":"totalChapters"}},{"kind":"Field","name":{"kind":"Name","value":"prevChapterOrder"}},{"kind":"Field","name":{"kind":"Name","value":"nextChapterOrder"}}]}}]}}]} as unknown as DocumentNode<GetChapterQuery, GetChapterQueryVariables>;
export const NovelDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Novel"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UnsignedInt"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novels"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"id"},"value":{"kind":"ObjectValue","fields":[{"kind":"ObjectField","name":{"kind":"Name","value":"eq"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}}]}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"IntValue","value":"1"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"nodes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"rawLanguage"}},{"kind":"Field","name":{"kind":"Name","value":"rawStatus"}},{"kind":"Field","name":{"kind":"Name","value":"statusOverride"}},{"kind":"Field","name":{"kind":"Name","value":"externalId"}},{"kind":"Field","name":{"kind":"Name","value":"createdTime"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"author"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"externalUrl"}}]}},{"kind":"Field","name":{"kind":"Name","value":"source"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"url"}}]}},{"kind":"Field","name":{"kind":"Name","value":"coverImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"tags"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"tagType"}}]}},{"kind":"Field","name":{"kind":"Name","value":"chapters"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"order"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"images"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode<NovelQuery, NovelQueryVariables>;
export const NovelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Novels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"after"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"where"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"NovelDtoFilterInput"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"order"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"NovelDtoSortInput"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"novels"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}},{"kind":"Argument","name":{"kind":"Name","value":"after"},"value":{"kind":"Variable","name":{"kind":"Name","value":"after"}}},{"kind":"Argument","name":{"kind":"Name","value":"where"},"value":{"kind":"Variable","name":{"kind":"Name","value":"where"}}},{"kind":"Argument","name":{"kind":"Name","value":"order"},"value":{"kind":"Variable","name":{"kind":"Name","value":"order"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"edges"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cursor"}},{"kind":"Field","name":{"kind":"Name","value":"node"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"coverImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"newPath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"rawStatus"}},{"kind":"Field","name":{"kind":"Name","value":"lastUpdatedTime"}},{"kind":"Field","name":{"kind":"Name","value":"chapters"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"order"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"tags"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"tagType"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}}]}}]}}]}}]} as unknown as DocumentNode<NovelsQuery, NovelsQueryVariables>;
export const GetSettingsPageDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetSettingsPageData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentUser"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"username"}},{"kind":"Field","name":{"kind":"Name","value":"availableInvites"}},{"kind":"Field","name":{"kind":"Name","value":"invitedUsers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"username"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}}]}}]}}]} as unknown as DocumentNode<GetSettingsPageDataQuery, GetSettingsPageDataQueryVariables>;

View File

@@ -0,0 +1,14 @@
mutation InviteUser($input: InviteUserInput!) {
inviteUser(input: $input) {
userDto {
id
username
email
}
errors {
... on InvalidOperationError {
message
}
}
}
}

View File

@@ -0,0 +1,11 @@
query GetSettingsPageData {
currentUser {
id
username
availableInvites
invitedUsers {
username
email
}
}
}

View File

@@ -0,0 +1,8 @@
---
import AppLayout from '../../layouts/AppLayout.astro';
import SettingsPage from '../../lib/components/SettingsPage.svelte';
---
<AppLayout title="Settings - FictionArchive">
<SettingsPage client:load />
</AppLayout>