Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Some naming conventions used in this module:
32
: the base32 representation of a hashexpect
: retrieve something that's known to existload
: retrieve something that's not known to exist (so the return type is a Maybe, or another container that could be empty)save
: idempotent (on conflict do nothing) insert, and return the id of the thing (usually)
Synopsis
- saveText :: Text -> Transaction TextId
- saveTexts :: Traversable f => f Text -> Transaction (f TextId)
- loadTextId :: Text -> Transaction (Maybe TextId)
- expectTextId :: Text -> Transaction TextId
- expectText :: TextId -> Transaction Text
- expectTextCheck :: SqliteExceptionReason e => TextId -> (Text -> Either e a) -> Transaction a
- saveNameSegment :: NameSegment -> Transaction TextId
- expectNameSegment :: TextId -> Transaction NameSegment
- saveHash :: Hash32 -> Transaction HashId
- saveHashes :: Traversable f => f Hash32 -> Transaction (f HashId)
- saveHashHash :: Hash -> Transaction HashId
- loadHashId :: Hash32 -> Transaction (Maybe HashId)
- expectHash :: HashId -> Transaction Hash
- expectHash32 :: HashId -> Transaction Hash32
- expectBranchHash :: BranchHashId -> Transaction BranchHash
- expectBranchHashId :: BranchHash -> Transaction BranchHashId
- loadHashIdByHash :: Hash -> Transaction (Maybe HashId)
- expectHashIdByHash :: Hash -> Transaction HashId
- saveCausalHash :: CausalHash -> Transaction CausalHashId
- expectCausalHash :: CausalHashId -> Transaction CausalHash
- expectBranchHashForCausalHash :: CausalHash -> Transaction BranchHash
- saveBranchHash :: BranchHash -> Transaction BranchHashId
- saveHashObject :: HashId -> ObjectId -> HashVersion -> Transaction ()
- expectHashIdsForObject :: ObjectId -> Transaction (NonEmpty HashId)
- hashIdWithVersionForObject :: ObjectId -> Transaction [(HashId, HashVersion)]
- loadObjectIdForPrimaryHashId :: HashId -> Transaction (Maybe ObjectId)
- expectObjectIdForPrimaryHashId :: HashId -> Transaction ObjectId
- loadObjectIdForPrimaryHash :: Hash -> Transaction (Maybe ObjectId)
- expectObjectIdForPrimaryHash :: Hash -> Transaction ObjectId
- loadPatchObjectIdForPrimaryHash :: PatchHash -> Transaction (Maybe PatchObjectId)
- loadObjectIdForAnyHash :: Hash -> Transaction (Maybe ObjectId)
- loadObjectIdForAnyHashId :: HashId -> Transaction (Maybe ObjectId)
- expectObjectIdForAnyHashId :: HashId -> Transaction ObjectId
- recordObjectRehash :: ObjectId -> ObjectId -> Transaction ()
- saveObject :: HashHandle -> HashId -> ObjectType -> ByteString -> Transaction ObjectId
- isObjectHash :: HashId -> Transaction Bool
- expectObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a
- expectPrimaryHashByObjectId :: ObjectId -> Transaction Hash
- expectPrimaryHashIdForObject :: ObjectId -> Transaction HashId
- expectObjectWithHashIdAndType :: ObjectId -> Transaction (HashId, ObjectType, ByteString)
- expectDeclObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a
- loadDeclObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a)
- expectNamespaceObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a
- loadNamespaceObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a)
- expectPatchObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a
- loadPatchObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a)
- loadTermObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a)
- expectTermObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a
- saveNamespaceStats :: BranchHashId -> NamespaceStats -> Transaction ()
- loadNamespaceStatsByHashId :: BranchHashId -> Transaction (Maybe NamespaceStats)
- saveCausal :: HashHandle -> CausalHashId -> BranchHashId -> [CausalHashId] -> Transaction ()
- isCausalHash :: HashId -> Transaction Bool
- causalExistsByHash32 :: Hash32 -> Transaction Bool
- expectCausal :: CausalHashId -> Transaction SyncCausalFormat
- loadCausalHashIdByCausalHash :: CausalHash -> Transaction (Maybe CausalHashId)
- expectCausalHashIdByCausalHash :: CausalHash -> Transaction CausalHashId
- expectCausalValueHashId :: CausalHashId -> Transaction BranchHashId
- loadCausalByCausalHash :: CausalHash -> Transaction (Maybe (CausalHashId, BranchHashId))
- expectCausalByCausalHash :: CausalHash -> Transaction (CausalHashId, BranchHashId)
- loadBranchObjectIdByCausalHashId :: CausalHashId -> Transaction (Maybe BranchObjectId)
- loadBranchObjectIdByBranchHashId :: BranchHashId -> Transaction (Maybe BranchObjectId)
- expectBranchObjectIdByCausalHashId :: CausalHashId -> Transaction BranchObjectId
- expectBranchObjectIdByBranchHashId :: BranchHashId -> Transaction BranchObjectId
- tryGetSquashResult :: BranchHashId -> Transaction (Maybe CausalHashId)
- saveSquashResult :: BranchHashId -> CausalHashId -> Transaction ()
- saveCausalParents :: CausalHashId -> [CausalHashId] -> Transaction ()
- loadCausalParents :: CausalHashId -> Transaction [CausalHashId]
- loadCausalParentsByHash :: Hash32 -> Transaction [Hash32]
- before :: CausalHashId -> CausalHashId -> Transaction Bool
- lca :: CausalHashId -> CausalHashId -> Transaction (Maybe CausalHashId)
- saveWatch :: WatchKind -> IdH -> ByteString -> Transaction ()
- loadWatch :: SqliteExceptionReason e => WatchKind -> IdH -> (ByteString -> Either e a) -> Transaction (Maybe a)
- loadWatchesByWatchKind :: WatchKind -> Transaction [IdH]
- loadWatchKindsByReference :: IdH -> Transaction [WatchKind]
- clearWatches :: Transaction ()
- projectExists :: ProjectId -> Transaction Bool
- doProjectsExist :: Transaction Bool
- projectExistsByName :: ProjectName -> Transaction Bool
- loadProject :: ProjectId -> Transaction (Maybe Project)
- loadProjectByName :: ProjectName -> Transaction (Maybe Project)
- expectProject :: ProjectId -> Transaction Project
- loadAllProjects :: Transaction [Project]
- loadAllProjectsBeginningWith :: Maybe Text -> Transaction [Project]
- insertProject :: ProjectId -> ProjectName -> Transaction ()
- renameProject :: ProjectId -> ProjectName -> Transaction ()
- deleteProject :: ProjectId -> Transaction ()
- projectBranchExistsByName :: ProjectId -> ProjectBranchName -> Transaction Bool
- loadProjectBranchByName :: ProjectId -> ProjectBranchName -> Transaction (Maybe ProjectBranch)
- loadProjectBranchByNames :: ProjectName -> ProjectBranchName -> Transaction (Maybe ProjectBranch)
- expectProjectBranch :: ProjectId -> ProjectBranchId -> Transaction ProjectBranch
- loadAllProjectBranchesBeginningWith :: ProjectId -> Maybe Text -> Transaction [(ProjectBranchId, ProjectBranchName)]
- loadAllProjectBranchInfo :: ProjectId -> Transaction (Map ProjectBranchName (Map URI (ProjectName, ProjectBranchName)))
- loadProjectAndBranchNames :: ProjectId -> ProjectBranchId -> Transaction (Maybe (ProjectName, ProjectBranchName))
- loadAllProjectBranchNamePairs :: Transaction [(ProjectAndBranch ProjectName ProjectBranchName, ProjectAndBranch ProjectId ProjectBranchId)]
- loadProjectBranch :: ProjectId -> ProjectBranchId -> Transaction (Maybe ProjectBranch)
- insertProjectBranch :: HasCallStack => Text -> CausalHashId -> ProjectBranch -> Transaction ()
- renameProjectBranch :: ProjectId -> ProjectBranchId -> ProjectBranchName -> Transaction ()
- deleteProjectBranch :: HasCallStack => ProjectId -> ProjectBranchId -> Transaction ()
- setProjectBranchHead :: Text -> ProjectId -> ProjectBranchId -> CausalHashId -> Transaction ()
- expectProjectBranchHead :: HasCallStack => ProjectId -> ProjectBranchId -> Transaction CausalHashId
- setMostRecentBranch :: ProjectId -> ProjectBranchId -> Transaction ()
- loadMostRecentBranch :: ProjectId -> Transaction (Maybe ProjectBranchId)
- loadRemoteProject :: RemoteProjectId -> URI -> Transaction (Maybe RemoteProject)
- ensureRemoteProject :: RemoteProjectId -> URI -> ProjectName -> Transaction ()
- expectRemoteProjectName :: RemoteProjectId -> URI -> Transaction ProjectName
- setRemoteProjectName :: RemoteProjectId -> ProjectName -> Transaction ()
- loadRemoteProjectBranch :: ProjectId -> URI -> ProjectBranchId -> Transaction (Maybe (RemoteProjectId, Maybe RemoteProjectBranchId))
- loadDefaultMergeTargetForLocalProjectBranch :: ProjectId -> URI -> ProjectBranchId -> Transaction (Maybe (RemoteProjectId, RemoteProjectBranchId))
- loadRemoteBranch :: RemoteProjectId -> URI -> RemoteProjectBranchId -> Transaction (Maybe RemoteProjectBranch)
- ensureRemoteProjectBranch :: RemoteProjectId -> URI -> RemoteProjectBranchId -> ProjectBranchName -> Transaction ()
- expectRemoteProjectBranchName :: URI -> RemoteProjectId -> RemoteProjectBranchId -> Transaction ProjectBranchName
- setRemoteProjectBranchName :: RemoteProjectId -> URI -> RemoteProjectBranchId -> ProjectBranchName -> Transaction ()
- insertBranchRemoteMapping :: ProjectId -> ProjectBranchId -> RemoteProjectId -> URI -> RemoteProjectBranchId -> Transaction ()
- ensureBranchRemoteMapping :: ProjectId -> ProjectBranchId -> RemoteProjectId -> URI -> RemoteProjectBranchId -> Transaction ()
- deleteBranchRemoteMapping :: ProjectId -> ProjectBranchId -> URI -> Transaction ()
- addToDependentsIndex :: [Reference] -> Id -> Transaction ()
- data DependentsSelector
- getDependentsForDependency :: DependentsSelector -> Reference -> Transaction (Set Id)
- getDependentsForDependencyComponent :: ObjectId -> Transaction [Id]
- getDependenciesForDependent :: Id -> Transaction [Reference]
- getDependencyIdsForDependent :: Id -> Transaction [Id]
- getDependenciesBetweenTerms :: ObjectId -> ObjectId -> Transaction (Set ObjectId)
- getDirectDependenciesOfScope :: DefnsF Set TermReferenceId TypeReferenceId -> Transaction (DefnsF Set TermReference TypeReference)
- getDirectDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId)
- getTransitiveDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId)
- addToTypeIndex :: ReferenceH -> Id -> Transaction ()
- getReferentsByType :: ReferenceH -> Transaction [Id]
- getTypeReferenceForReferent :: Id -> Transaction ReferenceH
- getTypeReferencesForComponent :: ObjectId -> Transaction [(ReferenceH, Id)]
- filterTermsByReferenceHavingType :: ReferenceH -> [Id] -> Transaction [Id]
- filterTermsByReferentHavingType :: ReferenceH -> [Id] -> Transaction [Id]
- addToTypeMentionsIndex :: ReferenceH -> Id -> Transaction ()
- getReferentsByTypeMention :: ReferenceH -> Transaction [Id]
- getTypeMentionsReferencesForComponent :: ObjectId -> Transaction [(ReferenceH, Id)]
- objectIdByBase32Prefix :: ObjectType -> Text -> Transaction [ObjectId]
- namespaceHashIdByBase32Prefix :: Text -> Transaction [BranchHashId]
- causalHashIdByBase32Prefix :: Text -> Transaction [CausalHashId]
- copyScopedNameLookup :: BranchHashId -> BranchHashId -> Transaction ()
- insertScopedTermNames :: BranchHashId -> [NamedRef (TextReferent, Maybe ConstructorType)] -> Transaction ()
- insertScopedTypeNames :: BranchHashId -> [NamedRef TextReference] -> Transaction ()
- removeScopedTermNames :: BranchHashId -> [NamedRef TextReferent] -> Transaction ()
- removeScopedTypeNames :: BranchHashId -> [NamedRef TextReference] -> Transaction ()
- termNamesWithinNamespace :: BranchHashId -> PathSegments -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)]
- typeNamesWithinNamespace :: BranchHashId -> PathSegments -> Transaction [NamedRef TextReference]
- termNamesForRefWithinNamespace :: BranchHashId -> PathSegments -> TextReferent -> Maybe ReversedName -> Transaction [ReversedName]
- typeNamesForRefWithinNamespace :: BranchHashId -> PathSegments -> TextReference -> Maybe ReversedName -> Transaction [ReversedName]
- recursiveTermNameSearch :: BranchHashId -> TextReferent -> Transaction (Maybe ReversedName)
- recursiveTypeNameSearch :: BranchHashId -> TextReference -> Transaction (Maybe ReversedName)
- termRefsForExactName :: BranchHashId -> ReversedName -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)]
- typeRefsForExactName :: BranchHashId -> ReversedName -> Transaction [NamedRef TextReference]
- checkBranchHashNameLookupExists :: BranchHashId -> Transaction Bool
- trackNewBranchHashNameLookup :: BranchHashId -> Transaction ()
- deleteNameLookup :: BranchHashId -> Transaction ()
- termNamesBySuffix :: BranchHashId -> PathSegments -> ReversedName -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)]
- typeNamesBySuffix :: BranchHashId -> PathSegments -> ReversedName -> Transaction [NamedRef TextReference]
- longestMatchingTermNameForSuffixification :: BranchHashId -> PathSegments -> NamedRef TextReferent -> Transaction (Maybe (NamedRef (TextReferent, Maybe ConstructorType)))
- longestMatchingTypeNameForSuffixification :: BranchHashId -> PathSegments -> NamedRef TextReference -> Transaction (Maybe (NamedRef TextReference))
- associateNameLookupMounts :: BranchHashId -> [(PathSegments, BranchHashId)] -> Transaction ()
- listNameLookupMounts :: BranchHashId -> Transaction [(PathSegments, BranchHashId)]
- deleteNameLookupsExceptFor :: [BranchHashId] -> Transaction ()
- fuzzySearchTerms :: Bool -> BranchHashId -> Int -> PathSegments -> [Text] -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)]
- fuzzySearchTypes :: Bool -> BranchHashId -> Int -> PathSegments -> [Text] -> Transaction [NamedRef TextReference]
- getDeprecatedRootReflog :: Int -> Transaction [Entry CausalHashId Text]
- appendProjectBranchReflog :: Entry ProjectId ProjectBranchId CausalHashId -> Transaction ()
- getProjectReflog :: Int -> ProjectId -> Transaction [Entry ProjectId ProjectBranchId CausalHashId]
- getProjectBranchReflog :: Int -> ProjectBranchId -> Transaction [Entry ProjectId ProjectBranchId CausalHashId]
- getGlobalReflog :: Int -> Transaction [Entry ProjectId ProjectBranchId CausalHashId]
- garbageCollectObjectsWithoutHashes :: Transaction ()
- garbageCollectWatchesWithoutObjects :: Transaction ()
- data EntityLocation
- entityExists :: Hash32 -> Transaction Bool
- entityLocation :: Hash32 -> Transaction (Maybe EntityLocation)
- expectEntity :: Hash32 -> Transaction SyncEntity
- syncToTempEntity :: SyncEntity -> Transaction TempEntity
- insertTempEntity :: Hash32 -> TempEntity -> NEMap Hash32 Text -> Transaction ()
- saveTempEntityInMain :: HashHandle -> Hash32 -> TempEntity -> Transaction (Either CausalHashId ObjectId)
- expectTempEntity :: Hash32 -> Transaction TempEntity
- deleteTempEntity :: Hash32 -> Transaction ()
- clearTempEntityTables :: Transaction ()
- elaborateHashes :: NonEmpty Hash32 -> Transaction [Text]
- expectCurrentProjectPath :: HasCallStack => Transaction (ProjectId, ProjectBranchId, [NameSegment])
- setCurrentProjectPath :: ProjectId -> ProjectBranchId -> [NameSegment] -> Transaction ()
- runCreateSql :: Transaction ()
- addTempEntityTables :: Transaction ()
- addReflogTable :: Transaction ()
- addNamespaceStatsTables :: Transaction ()
- addProjectTables :: Transaction ()
- addMostRecentBranchTable :: Transaction ()
- fixScopedNameLookupTables :: Transaction ()
- addNameLookupMountTables :: Transaction ()
- addMostRecentNamespaceTable :: Transaction ()
- addSquashResultTable :: Transaction ()
- addSquashResultTableIfNotExists :: Transaction ()
- cdToProjectRoot :: Transaction ()
- addCurrentProjectPathTable :: Transaction ()
- addProjectBranchReflogTable :: Transaction ()
- addProjectBranchCausalHashIdColumn :: Transaction ()
- currentSchemaVersion :: SchemaVersion
- expectSchemaVersion :: SchemaVersion -> Transaction ()
- setSchemaVersion :: SchemaVersion -> Transaction ()
- countObjects :: Transaction Int
- countCausals :: Transaction Int
- countWatches :: Transaction Int
- getCausalsWithoutBranchObjects :: Transaction [CausalHashId]
- removeHashObjectsByHashingVersion :: HashVersion -> Transaction ()
- addTypeMentionsToIndexForTerm :: Id -> Set Reference -> Transaction ()
- addTypeToIndexForTerm :: Id -> Reference -> Transaction ()
- c2xTerm :: forall m t d. Monad m => (Text -> m t) -> (Hash -> m d) -> Term Symbol -> Maybe (Type Symbol) -> m (LocalIds' t d, Term, Maybe Type)
- localIdsToLookups :: Monad m => (t -> m Text) -> (d -> m Hash) -> LocalIds' t d -> m (LocalTextId -> Text, LocalDefnId -> Hash)
- s2cDecl :: LocalIds -> Decl Symbol -> Transaction (Decl Symbol)
- s2cTermWithType :: LocalIds -> Term -> Type -> Transaction (Term Symbol, Type Symbol)
- saveDeclComponent :: HashHandle -> Maybe ByteString -> Hash -> [Decl Symbol] -> Transaction ObjectId
- saveReferenceH :: Reference -> Transaction ReferenceH
- saveSyncEntity :: HashHandle -> Hash32 -> SyncEntity -> Transaction (Either CausalHashId ObjectId)
- saveTermComponent :: HashHandle -> Maybe ByteString -> Hash -> [(Term Symbol, Type Symbol)] -> Transaction ObjectId
- schemaVersion :: Transaction SchemaVersion
- x2cTType :: (LocalTextId -> Text) -> (LocalDefnId -> Hash) -> Type -> Type Symbol
- x2cTerm :: (LocalTextId -> Text) -> (LocalDefnId -> Hash) -> Term -> Term Symbol
- x2cDecl :: (r -> r1) -> DeclR r Symbol -> DeclR r1 Symbol
- checkBranchExistsForCausalHash :: CausalHash -> Transaction Bool
- type NamespaceText = Text
- type TextPathSegments = [Text]
- data JsonParseFailure = JsonParseFailure {}
text table
saveTexts :: Traversable f => f Text -> Transaction (f TextId) Source #
loadTextId :: Text -> Transaction (Maybe TextId) Source #
expectTextId :: Text -> Transaction TextId Source #
expectText :: TextId -> Transaction Text Source #
expectTextCheck :: SqliteExceptionReason e => TextId -> (Text -> Either e a) -> Transaction a Source #
name segments
hash table
saveHashes :: Traversable f => f Hash32 -> Transaction (f HashId) Source #
saveHashHash :: Hash -> Transaction HashId Source #
loadHashId :: Hash32 -> Transaction (Maybe HashId) Source #
expectHash :: HashId -> Transaction Hash Source #
expectHash32 :: HashId -> Transaction Hash32 Source #
loadHashIdByHash :: Hash -> Transaction (Maybe HashId) Source #
hash_object table
saveHashObject :: HashId -> ObjectId -> HashVersion -> Transaction () Source #
expectObjectIdForPrimaryHashId :: HashId -> Transaction ObjectId Source #
Not all hashes have corresponding objects; e.g., hashes of term types
recordObjectRehash :: ObjectId -> ObjectId -> Transaction () Source #
recordObjectRehash old new
records that object old
was rehashed and inserted as a new object, new
.
This function rewrites old
's hash_object
rows in place to point at the new object.
object table
saveObject :: HashHandle -> HashId -> ObjectType -> ByteString -> Transaction ObjectId Source #
isObjectHash :: HashId -> Transaction Bool Source #
Does a hash correspond to an object?
expectObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a Source #
expectPrimaryHashByObjectId :: ObjectId -> Transaction Hash Source #
All objects have corresponding hashes.
expectDeclObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a Source #
Expect a decl component object.
loadDeclObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a) Source #
Load a decl component object.
expectNamespaceObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a Source #
Expect a namespace object.
loadNamespaceObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a) Source #
Load a namespace object.
expectPatchObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a Source #
Expect a patch object.
loadPatchObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a) Source #
Load a patch object.
loadTermObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction (Maybe a) Source #
Load a term component object.
expectTermObject :: SqliteExceptionReason e => ObjectId -> (ByteString -> Either e a) -> Transaction a Source #
Expect a term component object.
namespace_statistics table
saveNamespaceStats :: BranchHashId -> NamespaceStats -> Transaction () Source #
Save statistics about a given branch.
loadNamespaceStatsByHashId :: BranchHashId -> Transaction (Maybe NamespaceStats) Source #
Looks up statistics for a given branch, there's no guarantee that we have computed and saved stats for any given branch.
causals
causal table
saveCausal :: HashHandle -> CausalHashId -> BranchHashId -> [CausalHashId] -> Transaction () Source #
Maybe we would generalize this to something other than NamespaceHash if we end up wanting to store other kinds of Causals here too.
isCausalHash :: HashId -> Transaction Bool Source #
causalExistsByHash32 :: Hash32 -> Transaction Bool Source #
Return whether or not a causal exists with the given hash32.
tryGetSquashResult :: BranchHashId -> Transaction (Maybe CausalHashId) Source #
Get the causal hash result from squashing the provided branch hash if we've squashed it at some point in the past.
saveSquashResult :: BranchHashId -> CausalHashId -> Transaction () Source #
Save the result of running a squash on the provided branch hash id.
causal_parent table
saveCausalParents :: CausalHashId -> [CausalHashId] -> Transaction () Source #
loadCausalParentsByHash :: Hash32 -> Transaction [Hash32] Source #
Like loadCausalParents
, but the input and outputs are hashes, not hash ids.
before :: CausalHashId -> CausalHashId -> Transaction Bool Source #
before x y
returns whether or not x
occurred before y
, i.e. x
is an ancestor of y
.
lca :: CausalHashId -> CausalHashId -> Transaction (Maybe CausalHashId) Source #
watch table
saveWatch :: WatchKind -> IdH -> ByteString -> Transaction () Source #
loadWatch :: SqliteExceptionReason e => WatchKind -> IdH -> (ByteString -> Either e a) -> Transaction (Maybe a) Source #
loadWatchesByWatchKind :: WatchKind -> Transaction [IdH] Source #
clearWatches :: Transaction () Source #
Delete all watches that were put by putWatch
.
projects
projectExists :: ProjectId -> Transaction Bool Source #
Does a project exist with this id?
doProjectsExist :: Transaction Bool Source #
Check if any projects exist
projectExistsByName :: ProjectName -> Transaction Bool Source #
Does a project exist by this name?
loadProject :: ProjectId -> Transaction (Maybe Project) Source #
loadAllProjects :: Transaction [Project] Source #
Load all projects.
loadAllProjectsBeginningWith :: Maybe Text -> Transaction [Project] Source #
Load all projects whose name matches a prefix.
insertProject :: ProjectId -> ProjectName -> Transaction () Source #
Insert a project
row.
renameProject :: ProjectId -> ProjectName -> Transaction () Source #
Rename a project
row.
Precondition: the new name is available.
deleteProject :: ProjectId -> Transaction () Source #
project branches
projectBranchExistsByName :: ProjectId -> ProjectBranchName -> Transaction Bool Source #
Does a project branch exist by this name?
loadProjectBranchByName :: ProjectId -> ProjectBranchName -> Transaction (Maybe ProjectBranch) Source #
loadProjectBranchByNames :: ProjectName -> ProjectBranchName -> Transaction (Maybe ProjectBranch) Source #
loadAllProjectBranchesBeginningWith :: ProjectId -> Maybe Text -> Transaction [(ProjectBranchId, ProjectBranchName)] Source #
Load all branch id/name pairs in a project whose name matches an optional prefix.
loadAllProjectBranchInfo :: ProjectId -> Transaction (Map ProjectBranchName (Map URI (ProjectName, ProjectBranchName))) Source #
Load info about all branches in a project, for display by the branches
command.
Each branch name maps to a possibly-empty collection of associated remote branches.
loadProjectAndBranchNames :: ProjectId -> ProjectBranchId -> Transaction (Maybe (ProjectName, ProjectBranchName)) Source #
loadAllProjectBranchNamePairs :: Transaction [(ProjectAndBranch ProjectName ProjectBranchName, ProjectAndBranch ProjectId ProjectBranchId)] Source #
Load ALL project/branch name pairs Useful for autocomplete/fuzzy-finding
insertProjectBranch :: HasCallStack => Text -> CausalHashId -> ProjectBranch -> Transaction () Source #
Insert a project branch.
renameProjectBranch :: ProjectId -> ProjectBranchId -> ProjectBranchName -> Transaction () Source #
Rename a project branch.
Precondition: the new name is available.
deleteProjectBranch :: HasCallStack => ProjectId -> ProjectBranchId -> Transaction () Source #
Delete a project branch.
Re-parenting happens in the obvious way:
Before:
main <- topic <- topic2
After deleting topic
:
main <- topic2
setProjectBranchHead :: Text -> ProjectId -> ProjectBranchId -> CausalHashId -> Transaction () Source #
Set project branch HEAD
expectProjectBranchHead :: HasCallStack => ProjectId -> ProjectBranchId -> Transaction CausalHashId Source #
setMostRecentBranch :: ProjectId -> ProjectBranchId -> Transaction () Source #
remote projects
loadRemoteProject :: RemoteProjectId -> URI -> Transaction (Maybe RemoteProject) Source #
ensureRemoteProject :: RemoteProjectId -> URI -> ProjectName -> Transaction () Source #
setRemoteProjectName :: RemoteProjectId -> ProjectName -> Transaction () Source #
loadRemoteProjectBranch :: ProjectId -> URI -> ProjectBranchId -> Transaction (Maybe (RemoteProjectId, Maybe RemoteProjectBranchId)) Source #
Determine the remote mapping for a local project/branch by looking at the mapping for the given pair, then falling back to the project of the nearest ancestor.
loadDefaultMergeTargetForLocalProjectBranch :: ProjectId -> URI -> ProjectBranchId -> Transaction (Maybe (RemoteProjectId, RemoteProjectBranchId)) Source #
Load the default merge target for a local branch (i.e. The nearest ancestor's remote mapping)
remote project branches
loadRemoteBranch :: RemoteProjectId -> URI -> RemoteProjectBranchId -> Transaction (Maybe RemoteProjectBranch) Source #
ensureRemoteProjectBranch :: RemoteProjectId -> URI -> RemoteProjectBranchId -> ProjectBranchName -> Transaction () Source #
expectRemoteProjectBranchName :: URI -> RemoteProjectId -> RemoteProjectBranchId -> Transaction ProjectBranchName Source #
setRemoteProjectBranchName :: RemoteProjectId -> URI -> RemoteProjectBranchId -> ProjectBranchName -> Transaction () Source #
insertBranchRemoteMapping :: ProjectId -> ProjectBranchId -> RemoteProjectId -> URI -> RemoteProjectBranchId -> Transaction () Source #
ensureBranchRemoteMapping :: ProjectId -> ProjectBranchId -> RemoteProjectId -> URI -> RemoteProjectBranchId -> Transaction () Source #
deleteBranchRemoteMapping :: ProjectId -> ProjectBranchId -> URI -> Transaction () Source #
indexes
dependents index
addToDependentsIndex :: [Reference] -> Id -> Transaction () Source #
data DependentsSelector Source #
Which dependents should be returned?
- IncludeAllDependents. Include all dependents, including references from one's own component-mates, and references from oneself (e.g. those in recursive functions)
- ExcludeSelf. Include all dependents, including references from one's own component-mates, but excluding actual self references (e.g. those in recursive functions).
- ExcludeOwnComponent. Include all dependents outside of one's own component.
getDependentsForDependency :: DependentsSelector -> Reference -> Transaction (Set Id) Source #
Get dependents of a dependency.
getDependenciesForDependent :: Id -> Transaction [Reference] Source #
Get non-self dependencies of a user-defined dependent.
getDependencyIdsForDependent :: Id -> Transaction [Id] Source #
Get non-self, user-defined dependencies of a user-defined dependent.
getDependenciesBetweenTerms :: ObjectId -> ObjectId -> Transaction (Set ObjectId) Source #
Given two term (components) A and B, return the set of all terms that are along any "dependency path" from A to B, not including A nor B; i.e., the transitive dependencies of A that are transitive dependents of B.
For example, if A depends on X and Y, X depends on Q, Y depends on Z, and X and Z depend on B...
- -X-----Q / A B / Y---Z
...then `getDependenciesBetweenTerms A B` would return the set {X Y Z}
getDirectDependenciesOfScope :: DefnsF Set TermReferenceId TypeReferenceId -> Transaction (DefnsF Set TermReference TypeReference) Source #
getDirectDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId) Source #
`getDirectDependentsWithinScope scope query` returns all direct dependents of query
that are in scope
(not
including query
itself).
getTransitiveDependentsWithinScope :: Set Id -> Set Reference -> Transaction (DefnsF Set TermReferenceId TypeReferenceId) Source #
`getTransitiveDependentsWithinScope scope query` returns all transitive dependents of query
that are in scope
(not including query
itself).
type index
addToTypeIndex :: ReferenceH -> Id -> Transaction () Source #
getReferentsByType :: ReferenceH -> Transaction [Id] Source #
getTypeReferencesForComponent :: ObjectId -> Transaction [(ReferenceH, Id)] Source #
filterTermsByReferenceHavingType :: ReferenceH -> [Id] -> Transaction [Id] Source #
filterTermsByReferentHavingType :: ReferenceH -> [Id] -> Transaction [Id] Source #
type mentions index
addToTypeMentionsIndex :: ReferenceH -> Id -> Transaction () Source #
hash prefix lookup
objectIdByBase32Prefix :: ObjectType -> Text -> Transaction [ObjectId] Source #
Name Lookup
copyScopedNameLookup :: BranchHashId -> BranchHashId -> Transaction () Source #
Copies existing name lookup rows but replaces their branch hash id; This is a low-level operation used as part of deriving a new name lookup index from an existing one as performantly as possible.
insertScopedTermNames :: BranchHashId -> [NamedRef (TextReferent, Maybe ConstructorType)] -> Transaction () Source #
Insert the given set of term names into the name lookup table
insertScopedTypeNames :: BranchHashId -> [NamedRef TextReference] -> Transaction () Source #
Insert the given set of type names into the name lookup table
removeScopedTermNames :: BranchHashId -> [NamedRef TextReferent] -> Transaction () Source #
Remove the given set of term names into the name lookup table
removeScopedTypeNames :: BranchHashId -> [NamedRef TextReference] -> Transaction () Source #
Remove the given set of term names into the name lookup table
termNamesWithinNamespace :: BranchHashId -> PathSegments -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of a term names in the provided name lookup and relative namespace. Includes dependencies, but not transitive dependencies.
typeNamesWithinNamespace :: BranchHashId -> PathSegments -> Transaction [NamedRef TextReference] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of a type names in the provided name lookup and relative namespace. Includes dependencies, but not transitive dependencies.
termNamesForRefWithinNamespace :: BranchHashId -> PathSegments -> TextReferent -> Maybe ReversedName -> Transaction [ReversedName] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of term names for a given Referent within a given namespace. Considers one level of dependencies, but not transitive dependencies.
typeNamesForRefWithinNamespace :: BranchHashId -> PathSegments -> TextReference -> Maybe ReversedName -> Transaction [ReversedName] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of type names for a given Reference within a given namespace. Considers one level of dependencies, but not transitive dependencies.
recursiveTermNameSearch :: BranchHashId -> TextReferent -> Transaction (Maybe ReversedName) Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Searches all dependencies transitively looking for the provided referent.
Prefer termNamesForRefWithinNamespace
in most cases.
This is slower and only necessary when resolving the name of references when you don't know which
dependency it may exist in.
Searching transitive dependencies is exponential so we want to replace this with a more efficient approach as soon as possible.
Note: this returns the first name it finds by searching in order of: Names in the current namespace, then names in the current namespace's dependencies, then through the current namespace's dependencies' dependencies, etc.
recursiveTypeNameSearch :: BranchHashId -> TextReference -> Transaction (Maybe ReversedName) Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Searches all dependencies transitively looking for the provided referent.
Prefer typeNamesForRefWithinNamespace
in most cases.
This is slower and only necessary when resolving the name of references when you don't know which
dependency it may exist in.
Searching transitive dependencies is exponential so we want to replace this with a more efficient approach as soon as possible.
Note: this returns the first name it finds by searching in order of: Names in the current namespace, then names in the current namespace's dependencies, then through the current namespace's dependencies' dependencies, etc.
termRefsForExactName :: BranchHashId -> ReversedName -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the set of refs for an exact name. This will only return results which are within the name lookup for the provided branch hash id. It's the caller's job to select the correct name lookup for your exact name.
See termRefsForExactName in U.Codebase.Sqlite.Operations
typeRefsForExactName :: BranchHashId -> ReversedName -> Transaction [NamedRef TextReference] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the set of refs for an exact name. This will only return results which are within the name lookup for the provided branch hash id. It's the caller's job to select the correct name lookup for your exact name.
See termRefsForExactName in U.Codebase.Sqlite.Operations
checkBranchHashNameLookupExists :: BranchHashId -> Transaction Bool Source #
Check if we've already got an index for the desired root branch hash.
trackNewBranchHashNameLookup :: BranchHashId -> Transaction () Source #
Inserts a new record into the name_lookups table
deleteNameLookup :: BranchHashId -> Transaction () Source #
Delete the specified name lookup. This should only be used if you're sure it's unused, or if you're going to re-create it in the same transaction.
termNamesBySuffix :: BranchHashId -> PathSegments -> ReversedName -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of term names within a given namespace which have the given suffix.
typeNamesBySuffix :: BranchHashId -> PathSegments -> ReversedName -> Transaction [NamedRef TextReference] Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
Get the list of type names within a given namespace which have the given suffix.
longestMatchingTermNameForSuffixification :: BranchHashId -> PathSegments -> NamedRef TextReferent -> Transaction (Maybe (NamedRef (TextReferent, Maybe ConstructorType))) Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
The goal of this query is to search the codebase for the single name which has a different hash from the provided name, but shares longest matching suffix for for that name.
Including this name in the pretty-printer object causes it to suffixify the name so that it is unambiguous from other names in scope.
Sqlite doesn't provide enough functionality to do this query in a single query, so we do it iteratively, querying for longer and longer suffixes we no longer find matches. Then we return the name with longest matching suffix.
This is still relatively efficient because we can use an index and LIMIT 1 to make each individual query fast, and in the common case we'll only need two or three queries to find the longest matching suffix.
Considers one level of dependencies, but not transitive dependencies.
longestMatchingTypeNameForSuffixification :: BranchHashId -> PathSegments -> NamedRef TextReference -> Transaction (Maybe (NamedRef TextReference)) Source #
NOTE: requires that the codebase has an up-to-date name lookup index. As of writing, this is only true on Share.
The goal of this query is to search the codebase for the single name which has a different hash from the provided name, but shares longest matching suffix for for that name.
Including this name in the pretty-printer object causes it to suffixify the name so that it is unambiguous from other names in scope.
Sqlite doesn't provide enough functionality to do this query in a single query, so we do it iteratively, querying for longer and longer suffixes we no longer find matches. Then we return the name with longest matching suffix.
This is still relatively efficient because we can use an index and LIMIT 1 to make each individual query fast, and in the common case we'll only need two or three queries to find the longest matching suffix.
Considers one level of dependencies, but not transitive dependencies.
associateNameLookupMounts :: BranchHashId -> [(PathSegments, BranchHashId)] -> Transaction () Source #
Associate name lookup indexes for dependencies to specific mounting points within another name lookup.
listNameLookupMounts :: BranchHashId -> Transaction [(PathSegments, BranchHashId)] Source #
Fetch the name lookup mounts for a given name lookup index.
deleteNameLookupsExceptFor :: [BranchHashId] -> Transaction () Source #
Delete any name lookup that's not in the provided list.
This can be used to garbage collect unreachable name lookups.
fuzzySearchTerms :: Bool -> BranchHashId -> Int -> PathSegments -> [Text] -> Transaction [NamedRef (TextReferent, Maybe ConstructorType)] Source #
Searches for all names within the given name lookup which contain the provided list of segments in order. Search is case insensitive.
fuzzySearchTypes :: Bool -> BranchHashId -> Int -> PathSegments -> [Text] -> Transaction [NamedRef TextReference] Source #
Searches for all names within the given name lookup which contain the provided list of segments in order.
Search is case insensitive.
Reflog
appendProjectBranchReflog :: Entry ProjectId ProjectBranchId CausalHashId -> Transaction () Source #
getProjectReflog :: Int -> ProjectId -> Transaction [Entry ProjectId ProjectBranchId CausalHashId] Source #
Get x number of entries from the project reflog for the provided project
getProjectBranchReflog :: Int -> ProjectBranchId -> Transaction [Entry ProjectId ProjectBranchId CausalHashId] Source #
Get x number of entries from the project reflog for the provided branch.
getGlobalReflog :: Int -> Transaction [Entry ProjectId ProjectBranchId CausalHashId] Source #
Get x number of entries from the global reflog spanning all projects
garbage collection
garbageCollectObjectsWithoutHashes :: Transaction () Source #
Delete objects without hashes. An object typically *would* have a hash, but (for example) during a migration in which an object's hash may change, its corresponding hash_object row may be updated to point at a new version of that object. This procedure clears out all references to objects that do not have any corresponding hash_object rows.
garbageCollectWatchesWithoutObjects :: Transaction () Source #
Delete all
sync temp entities
data EntityLocation Source #
Where an entity is stored.
EntityInMainStorage |
|
EntityInTempStorage |
|
Instances
Show EntityLocation Source # | |
Defined in U.Codebase.Sqlite.Queries showsPrec :: Int -> EntityLocation -> ShowS # show :: EntityLocation -> String # showList :: [EntityLocation] -> ShowS # | |
Eq EntityLocation Source # | |
Defined in U.Codebase.Sqlite.Queries (==) :: EntityLocation -> EntityLocation -> Bool # (/=) :: EntityLocation -> EntityLocation -> Bool # | |
Ord EntityLocation Source # | |
Defined in U.Codebase.Sqlite.Queries compare :: EntityLocation -> EntityLocation -> Ordering # (<) :: EntityLocation -> EntityLocation -> Bool # (<=) :: EntityLocation -> EntityLocation -> Bool # (>) :: EntityLocation -> EntityLocation -> Bool # (>=) :: EntityLocation -> EntityLocation -> Bool # max :: EntityLocation -> EntityLocation -> EntityLocation # min :: EntityLocation -> EntityLocation -> EntityLocation # |
entityExists :: Hash32 -> Transaction Bool Source #
Does this entity already exist in the database, i.e. in the object
or causal
table?
entityLocation :: Hash32 -> Transaction (Maybe EntityLocation) Source #
Where is an entity stored?
expectEntity :: Hash32 -> Transaction SyncEntity Source #
Read an entity out of main storage.
syncToTempEntity :: SyncEntity -> Transaction TempEntity Source #
looking up all of the text and hashes is the first step of converting a SyncEntity to a Share.Entity
insertTempEntity :: Hash32 -> TempEntity -> NEMap Hash32 Text -> Transaction () Source #
Insert a new temp_entity
row, and its associated 1+ temp_entity_missing_dependency
rows.
Preconditions:
1. The entity does not already exist in "main" storage (object
/ causal
)
2. The entity does not already exist in temp_entity
.
saveTempEntityInMain :: HashHandle -> Hash32 -> TempEntity -> Transaction (Either CausalHashId ObjectId) Source #
Save a temp entity in main storage.
Precondition: all of its dependencies are already in main storage.
expectTempEntity :: Hash32 -> Transaction TempEntity Source #
Read an entity out of temp storage.
deleteTempEntity :: Hash32 -> Transaction () Source #
Delete a row from the temp_entity
table, if it exists.
clearTempEntityTables :: Transaction () Source #
Clears the temp_entity
and temp_entity_missing_dependency
tables.
The hashjwts stored in temp entity tables can sometimes go stale, so we clear them out.
This is safe because temp entities are generally considered ephemeral
except during an active pull.
elaborate hashes
elaborateHashes :: NonEmpty Hash32 -> Transaction [Text] Source #
Elaborate a set of temp_entity
hashes.
Given a set of temp_entity
hashes, returns the (known) set of transitive dependencies that haven't already been
downloaded (i.e. aren't in the temp_entity
table)
For example, if we have temp entities A and B, where A depends on B and B depends on C...
| temp_entity | | temp_entity_missing_dependency | |=============| |================================| | hash | | dependent | dependency | |-------------| |--------------|-----------------| | A | | A | B | | B | | B | C |
... then `elaborateHashes {A}` would return the singleton set {C} (because we take the set of transitive dependencies {A,B,C} and subtract the set we already have, {A,B}).
current project path
expectCurrentProjectPath :: HasCallStack => Transaction (ProjectId, ProjectBranchId, [NameSegment]) Source #
Get the most recent namespace the user has visited.
setCurrentProjectPath :: ProjectId -> ProjectBranchId -> [NameSegment] -> Transaction () Source #
Set the most recent namespace the user has visited.
migrations
runCreateSql :: Transaction () Source #
addReflogTable :: Transaction () Source #
Deprecated in favour of project-branch reflog
addProjectTables :: Transaction () Source #
addSquashResultTableIfNotExists :: Transaction () Source #
Added as a fix because addSquashResultTable
was missed in the createSchema action
for a portion of time.
cdToProjectRoot :: Transaction () Source #
addProjectBranchReflogTable :: Transaction () Source #
Deprecated in favour of project-branch reflog
schema version
expectSchemaVersion :: SchemaVersion -> Transaction () Source #
Expect the given schema version.
setSchemaVersion :: SchemaVersion -> Transaction () Source #
helpers for various migrations
getCausalsWithoutBranchObjects :: Transaction [CausalHashId] Source #
Finds all causals that refer to a branch for which we don't have an object stored. Although there are plans to support this in the future, currently all such cases are the result of database inconsistencies and are unexpected.
removeHashObjectsByHashingVersion :: HashVersion -> Transaction () Source #
Delete all hash objects of a given hash version.
Leaves the corresponding hash
es in the hash table alone.
db misc
addTypeMentionsToIndexForTerm :: Id -> Set Reference -> Transaction () Source #
addTypeToIndexForTerm :: Id -> Reference -> Transaction () Source #
c2xTerm :: forall m t d. Monad m => (Text -> m t) -> (Hash -> m d) -> Term Symbol -> Maybe (Type Symbol) -> m (LocalIds' t d, Term, Maybe Type) Source #
implementation detail of c2{s,w}Term The Type is optional, because we don't store them for watch expression results.
localIdsToLookups :: Monad m => (t -> m Text) -> (d -> m Hash) -> LocalIds' t d -> m (LocalTextId -> Text, LocalDefnId -> Hash) Source #
implementation detail of {s,w}2c*Term* & s2cDecl
saveDeclComponent :: HashHandle -> Maybe ByteString -> Hash -> [Decl Symbol] -> Transaction ObjectId Source #
saveReferenceH :: Reference -> Transaction ReferenceH Source #
Save the text and hash parts of a Reference to the database and substitute their ids.
saveSyncEntity :: HashHandle -> Hash32 -> SyncEntity -> Transaction (Either CausalHashId ObjectId) Source #
:: HashHandle | |
-> Maybe ByteString | The serialized term component if we already have it e.g. via sync |
-> Hash | term component hash |
-> [(Term Symbol, Type Symbol)] | term component |
-> Transaction ObjectId |
x2cTType :: (LocalTextId -> Text) -> (LocalDefnId -> Hash) -> Type -> Type Symbol Source #
implementation detail of {s,w}2c*Term*
x2cTerm :: (LocalTextId -> Text) -> (LocalDefnId -> Hash) -> Term -> Term Symbol Source #
implementation detail of {s,w}2c*Term*
checkBranchExistsForCausalHash :: CausalHash -> Transaction Bool Source #
Checks whether the codebase contains the actual branch value for a given causal hash.
Types
type NamespaceText = Text Source #
A namespace rendered as a path, no leading .
E.g. "base.data"
type TextPathSegments = [Text] Source #
data JsonParseFailure Source #
Instances
Show JsonParseFailure Source # | |
Defined in U.Codebase.Sqlite.Queries showsPrec :: Int -> JsonParseFailure -> ShowS # show :: JsonParseFailure -> String # showList :: [JsonParseFailure] -> ShowS # | |
SqliteExceptionReason JsonParseFailure Source # | |
Defined in U.Codebase.Sqlite.Queries |