(parameters.Visibility).Value)
|> returnValueTask
- context.Items.Add("Command", nameof (SetVisibility))
+ context.Items.Add("Command", nameof (SetRepositoryType))
+ return! processCommand context validations command
+ }
+
+ /// Sets the number of days to keep an entity that has been logically deleted. After this time expires, the entity will be physically deleted.
+ let SetLogicalDeleteDays: HttpHandler =
+ fun (next: HttpFunc) (context: HttpContext) ->
+ task {
+ let validations (parameters: SetLogicalDeleteDaysParameters) =
+ [| Repository.daysIsValid parameters.LogicalDeleteDays InvalidLogicalDeleteDaysValue
+ Repository.repositoryIsNotDeleted context parameters.CorrelationId RepositoryIsDeleted |]
+
+ let command (parameters: SetLogicalDeleteDaysParameters) = SetLogicalDeleteDays(parameters.LogicalDeleteDays) |> returnValueTask
+
+ context.Items.Add("Command", nameof (SetLogicalDeleteDays))
return! processCommand context validations command
}
@@ -392,9 +402,7 @@ module Repository =
Repository.repositoryIsNotDeleted context parameters.CorrelationId RepositoryIsDeleted
Repository.repositoryNameIsUnique
parameters.OwnerId
- parameters.OwnerName
parameters.OrganizationId
- parameters.OrganizationName
parameters.NewName
parameters.CorrelationId
RepositoryNameAlreadyExists |]
diff --git a/src/Grace.Server/Services.Server.fs b/src/Grace.Server/Services.Server.fs
index a0014f1..89be075 100644
--- a/src/Grace.Server/Services.Server.fs
+++ b/src/Grace.Server/Services.Server.fs
@@ -87,7 +87,6 @@ module Services =
context.SetStatusCode(statusCode)
//log.LogDebug("{currentInstant}: In returnResult: StatusCode: {statusCode}; result: {result}", getCurrentInstantExtended(), statusCode, serialize result)
-
return! context.WriteJsonAsync(result) // .WriteJsonAsync() uses Grace's JsonSerializerOptions.
with ex ->
let exceptionResponse = Utilities.createExceptionResponse ex
diff --git a/src/Grace.Server/Startup.Server.fs b/src/Grace.Server/Startup.Server.fs
index 6ddb3ad..cbdb8e7 100644
--- a/src/Grace.Server/Startup.Server.fs
+++ b/src/Grace.Server/Startup.Server.fs
@@ -59,16 +59,16 @@ module Application =
let mustBeLoggedIn = requiresAuthentication notLoggedIn
+ let fileVersion =
+ FileVersionInfo
+ .GetVersionInfo(Assembly.GetExecutingAssembly().Location)
+ .FileVersion
+
let endpoints =
[ GET
[ route
"/"
(warbler (fun _ ->
- let fileVersion =
- FileVersionInfo
- .GetVersionInfo(Assembly.GetExecutingAssembly().Location)
- .FileVersion
-
htmlString
$"Hello From Grace Server {fileVersion}!
The current server time is: {getCurrentInstantExtended ()}.
"))
route
@@ -231,6 +231,8 @@ module Application =
|> addMetadata typeof
route "/setDescription" Repository.SetDescription
|> addMetadata typeof
+ route "/setLogicalDeleteDays" Repository.SetLogicalDeleteDays
+ |> addMetadata typeof
route "/setName" Repository.SetName
|> addMetadata typeof
route "/setRecordSaves" Repository.SetRecordSaves
@@ -496,6 +498,7 @@ module Application =
|> ignore
app
+ //.UseMiddleware()
.UseW3CLogging()
.UseCloudEvents()
.UseAuthentication()
diff --git a/src/Grace.Server/Validations.Server.fs b/src/Grace.Server/Validations.Server.fs
index 554ec91..1c570a6 100644
--- a/src/Grace.Server/Validations.Server.fs
+++ b/src/Grace.Server/Validations.Server.fs
@@ -350,10 +350,10 @@ module Validations =
}
|> ValidationResult
- let repositoryNameIsUnique<'T> ownerId ownerName organizationId organizationName repositoryName correlationId (error: 'T) =
+ let repositoryNameIsUnique<'T> ownerId organizationId repositoryName correlationId (error: 'T) =
task {
if not <| String.IsNullOrEmpty(repositoryName) then
- match! repositoryNameIsUnique ownerId ownerName organizationId organizationName repositoryName correlationId with
+ match! repositoryNameIsUnique ownerId organizationId repositoryName correlationId with
| Ok isUnique -> if isUnique then return Ok() else return Error error
| Error internalError ->
logToConsole internalError
@@ -399,39 +399,36 @@ module Validations =
|> ValidationResult
/// Validates that the branch exists in the database.
- let branchExists<'T> ownerId ownerName organizationId organizationName repositoryId repositoryName branchId branchName correlationId (error: 'T) =
+ let branchExists<'T> ownerId organizationId repositoryId branchId branchName correlationId (error: 'T) =
task {
let mutable branchGuid = Guid.Empty
- match! resolveRepositoryId ownerId ownerName organizationId organizationName repositoryId repositoryName correlationId with
- | Some repositoryId ->
- match! resolveBranchId repositoryId branchId branchName correlationId with
- | Some branchId ->
- if Guid.TryParse(branchId, &branchGuid) then
- let exists = memoryCache.Get(branchGuid)
+ match! resolveBranchId repositoryId branchId branchName correlationId with
+ | Some branchId ->
+ if Guid.TryParse(branchId, &branchGuid) then
+ let exists = memoryCache.Get(branchGuid)
- match exists with
- | MemoryCache.ExistsValue -> return Ok()
- | MemoryCache.DoesNotExistValue -> return Error error
- | _ ->
- let branchActorProxy = Branch.CreateActorProxy branchGuid correlationId
-
- let! exists = branchActorProxy.Exists correlationId
-
- if exists then
- use newCacheEntry =
- memoryCache.CreateEntry(
- branchGuid,
- Value = MemoryCache.ExistsValue,
- AbsoluteExpirationRelativeToNow = MemoryCache.DefaultExpirationTime
- )
-
- return Ok()
- else
- return Error error
- else
- return Error error
- | None -> return Error error
+ match exists with
+ | MemoryCache.ExistsValue -> return Ok()
+ | MemoryCache.DoesNotExistValue -> return Error error
+ | _ ->
+ let branchActorProxy = Branch.CreateActorProxy branchGuid correlationId
+
+ let! exists = branchActorProxy.Exists correlationId
+
+ if exists then
+ use newCacheEntry =
+ memoryCache.CreateEntry(
+ branchGuid,
+ Value = MemoryCache.ExistsValue,
+ AbsoluteExpirationRelativeToNow = MemoryCache.DefaultExpirationTime
+ )
+
+ return Ok()
+ else
+ return Error error
+ else
+ return Error error
| None -> return Error error
}
|> ValidationResult
@@ -525,13 +522,10 @@ module Validations =
|> ValidationResult
/// Validates that the given branchName does not exist in the database.
- let branchNameDoesNotExist<'T> ownerId ownerName organizationId organizationName repositoryId repositoryName branchName correlationId (error: 'T) =
+ let branchNameDoesNotExist<'T> ownerId organizationId repositoryId branchName correlationId (error: 'T) =
task {
- match! resolveRepositoryId ownerId ownerName organizationId organizationName repositoryId repositoryName correlationId with
- | Some repositoryId ->
- match! resolveBranchId repositoryId String.Empty branchName correlationId with
- | Some branchId -> return Error error
- | None -> return Ok()
+ match! resolveBranchId repositoryId String.Empty branchName correlationId with
+ | Some branchId -> return Error error
| None -> return Ok()
}
|> ValidationResult
diff --git a/src/Grace.Shared/Constants.Shared.fs b/src/Grace.Shared/Constants.Shared.fs
index 7cdbb04..e7d6a06 100644
--- a/src/Grace.Shared/Constants.Shared.fs
+++ b/src/Grace.Shared/Constants.Shared.fs
@@ -105,6 +105,7 @@ module Constants =
let GraceObjectCacheFile = "graceObjectCache.json.gz"
/// The default branch name for new repositories.
+ []
let InitialBranchName = "main"
/// The configuration version number used by this release of Grace.
diff --git a/src/Grace.Shared/Dto/Dto.Shared.fs b/src/Grace.Shared/Dto/Dto.Shared.fs
index c170bb6..62d337d 100644
--- a/src/Grace.Shared/Dto/Dto.Shared.fs
+++ b/src/Grace.Shared/Dto/Dto.Shared.fs
@@ -14,22 +14,24 @@ module Dto =
[]
type DiffDto =
{ Class: string
- HasDifferences: bool
+ RepositoryId: RepositoryId
DirectoryId1: DirectoryVersionId
Directory1CreatedAt: Instant
DirectoryId2: DirectoryVersionId
Directory2CreatedAt: Instant
+ HasDifferences: bool
Differences: List
FileDiffs: List }
static member Default =
{ Class = nameof (DiffDto)
- HasDifferences = false
+ RepositoryId = RepositoryId.Empty
DirectoryId1 = DirectoryVersionId.Empty
Directory1CreatedAt = Constants.DefaultTimestamp
DirectoryId2 = DirectoryVersionId.Empty
Directory2CreatedAt = Constants.DefaultTimestamp
Differences = List()
+ HasDifferences = false
FileDiffs = List() }
static member GetKnownTypes() = GetKnownTypes()
@@ -45,7 +47,6 @@ module Dto =
OrganizationType: OrganizationType
Description: string
SearchVisibility: SearchVisibility
- Repositories: Dictionary
CreatedAt: Instant
UpdatedAt: Instant option
DeletedAt: Instant option
@@ -59,7 +60,6 @@ module Dto =
OrganizationType = OrganizationType.Public
Description = String.Empty
SearchVisibility = Visible
- Repositories = new Dictionary()
CreatedAt = Constants.DefaultTimestamp
UpdatedAt = None
DeletedAt = None
@@ -77,7 +77,6 @@ module Dto =
OwnerType: OwnerType
Description: string
SearchVisibility: SearchVisibility
- Organizations: Dictionary
CreatedAt: Instant
UpdatedAt: Instant option
DeletedAt: Instant option
@@ -90,7 +89,6 @@ module Dto =
OwnerType = OwnerType.Public
Description = String.Empty
SearchVisibility = Visible
- Organizations = new Dictionary()
CreatedAt = Constants.DefaultTimestamp
UpdatedAt = None
DeletedAt = None
@@ -145,16 +143,15 @@ module Dto =
ObjectStorageProvider: ObjectStorageProvider
StorageAccountName: StorageAccountName
StorageContainerName: StorageContainerName
- RepositoryVisibility: RepositoryVisibility
+ RepositoryType: RepositoryType
RepositoryStatus: RepositoryStatus
- Branches: SortedSet
DefaultServerApiVersion: string
DefaultBranchName: BranchName
- LogicalDeleteDays: double
- SaveDays: double
- CheckpointDays: double
- DirectoryVersionCacheDays: double
- DiffCacheDays: double
+ LogicalDeleteDays: single
+ SaveDays: single
+ CheckpointDays: single
+ DirectoryVersionCacheDays: single
+ DiffCacheDays: single
Description: string
RecordSaves: bool
CreatedAt: Instant
@@ -172,16 +169,15 @@ module Dto =
ObjectStorageProvider = ObjectStorageProvider.Unknown
StorageAccountName = String.Empty
StorageContainerName = "grace-objects"
- RepositoryVisibility = RepositoryVisibility.Private
+ RepositoryType = RepositoryType.Private
RepositoryStatus = RepositoryStatus.Active
- Branches = SortedSet()
DefaultServerApiVersion = "latest"
DefaultBranchName = BranchName Constants.InitialBranchName
- LogicalDeleteDays = 30.0
- SaveDays = 7.0
- CheckpointDays = 365.0
- DirectoryVersionCacheDays = 1.0
- DiffCacheDays = 1.0
+ LogicalDeleteDays = 30.0f
+ SaveDays = 7.0f
+ CheckpointDays = 365.0f
+ DirectoryVersionCacheDays = 1.0f
+ DiffCacheDays = 1.0f
Description = String.Empty
RecordSaves = true
CreatedAt = Constants.DefaultTimestamp
diff --git a/src/Grace.Shared/Grace.Shared.fsproj b/src/Grace.Shared/Grace.Shared.fsproj
index e602930..414e7e2 100644
--- a/src/Grace.Shared/Grace.Shared.fsproj
+++ b/src/Grace.Shared/Grace.Shared.fsproj
@@ -54,22 +54,22 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
+
-
+