Repository navigation
feat(gremlin): add the projects of the core and of Azure Cosmos DB #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xperiandri
wants to merge
1
commit into
main
Choose a base branch
from
feat/gremlin-skeleton
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Auto-Generated by FAKE; do not edit | ||
| namespace System | ||
| open System.Reflection | ||
|
|
||
| [<assembly: AssemblyTitleAttribute("FSharp.Azure.Cosmos.Gremlin")>] | ||
| [<assembly: AssemblyProductAttribute("FSharp.Azure.Cosmos")>] | ||
| [<assembly: AssemblyVersionAttribute("1.2.0")>] | ||
| [<assembly: AssemblyMetadataAttribute("ReleaseDate","2026-10-01T00:00:00.0000000+02:00")>] | ||
| [<assembly: AssemblyFileVersionAttribute("1.2.0")>] | ||
| [<assembly: AssemblyInformationalVersionAttribute("1.2.0")>] | ||
| [<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>] | ||
| [<assembly: AssemblyMetadataAttribute("GitHash","210cf041a0ce44fcc5a5df369550a77a1f75d436")>] | ||
| do () | ||
|
|
||
| module internal AssemblyVersionInformation = | ||
| let [<Literal>] AssemblyTitle = "FSharp.Azure.Cosmos.Gremlin" | ||
| let [<Literal>] AssemblyProduct = "FSharp.Azure.Cosmos" | ||
| let [<Literal>] AssemblyVersion = "1.2.0" | ||
| let [<Literal>] AssemblyMetadata_ReleaseDate = "2026-10-01T00:00:00.0000000+02:00" | ||
| let [<Literal>] AssemblyFileVersion = "1.2.0" | ||
| let [<Literal>] AssemblyInformationalVersion = "1.2.0" | ||
| let [<Literal>] AssemblyMetadata_ReleaseChannel = "release" | ||
| let [<Literal>] AssemblyMetadata_GitHash = "210cf041a0ce44fcc5a5df369550a77a1f75d436" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| namespace FSharp.Azure.Cosmos.Gremlin | ||
|
|
||
| open System | ||
| open System.Text.RegularExpressions | ||
|
|
||
| /// <summary> | ||
| /// The settings that connect a client to a graph of Azure Cosmos DB for Apache Gremlin: the Gremlin endpoint, the | ||
| /// database, the graph and the key of the account. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <see cref="T:Microsoft.FSharp.Core.StructuredFormatDisplayAttribute"/> makes <c>ToString</c>, the format <c>%A</c> | ||
| /// and an interpolated string of the record give | ||
| /// <see cref="P:FSharp.Azure.Cosmos.Gremlin.CosmosGremlinConnection.Description"/>, which does not show | ||
| /// <see cref="P:FSharp.Azure.Cosmos.Gremlin.CosmosGremlinConnection.Key"/>. A structured logger that reads the public | ||
| /// properties of the record writes the key. Thus write | ||
| /// <see cref="P:FSharp.Azure.Cosmos.Gremlin.CosmosGremlinConnection.Description"/> to a log, not the record. | ||
| /// </remarks> | ||
| [<StructuredFormatDisplay("{Description}")>] | ||
| type CosmosGremlinConnection = { | ||
| /// <summary> | ||
| /// The host of the Gremlin endpoint, for example <c>myaccount.gremlin.cosmos.azure.com</c>. | ||
| /// </summary> | ||
| Host : string | ||
| /// The port of the Gremlin endpoint. | ||
| Port : int | ||
| /// <summary> | ||
| /// <see langword="true"/> to connect with TLS (<c>wss</c>), <see langword="false"/> to connect without TLS | ||
| /// (<c>ws</c>). | ||
| /// </summary> | ||
| UseSsl : bool | ||
| /// The id of the database. | ||
| Database : string | ||
| /// The id of the graph, which is a container of the database. | ||
| Graph : string | ||
| /// The primary or the secondary key of the account. | ||
| Key : string | ||
| } with | ||
|
|
||
| /// <summary> | ||
| /// The user name of the authentication: <c>/dbs/<database>/colls/<graph></c>. | ||
| /// </summary> | ||
| member this.UserName = $"/dbs/{this.Database}/colls/{this.Graph}" | ||
|
|
||
| /// <summary> | ||
| /// The settings without <see cref="P:FSharp.Azure.Cosmos.Gremlin.CosmosGremlinConnection.Key"/>, for example | ||
| /// <c>wss://myaccount.gremlin.cosmos.azure.com:443 /dbs/db1/colls/graph1</c>. | ||
| /// </summary> | ||
| member this.Description = | ||
| let scheme = if this.UseSsl then "wss" else "ws" | ||
| $"{scheme}://{this.Host}:{this.Port} {this.UserName}" | ||
|
|
||
| /// <summary> | ||
| /// Creates a <see cref="T:FSharp.Azure.Cosmos.Gremlin.CosmosGremlinConnection"/> for an account in Azure or for the | ||
| /// emulator. | ||
| /// </summary> | ||
| [<RequireQualifiedAccess>] | ||
| module CosmosGremlinConnection = | ||
|
|
||
| /// The well-known key of the Azure Cosmos DB Emulator. | ||
| [<Literal>] | ||
| let EmulatorKey = | ||
| "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" | ||
|
|
||
| /// The port of the Gremlin endpoint of an account in Azure. | ||
| [<Literal>] | ||
| let AzurePort = 443 | ||
|
|
||
| /// <summary> | ||
| /// The default port of the Gremlin endpoint of the Windows emulator. The emulator opens it when it starts with | ||
| /// <c>/EnableGremlinEndpoint</c>. | ||
| /// </summary> | ||
| [<Literal>] | ||
| let EmulatorPort = 8901 | ||
|
|
||
| // The rule of Azure for the name of a Cosmos DB account: 3 to 44 lowercase letters, numbers and hyphens, starting | ||
| // with a letter or a number. \z instead of $, because $ also matches before a final line feed. | ||
| let private accountName = Regex (@"\A[a-z0-9][a-z0-9-]{2,43}\z", RegexOptions.CultureInvariant) | ||
|
|
||
| // Cosmos DB does not allow these characters in the id of a database or a container. A slash would also change the | ||
| // path of the user name. | ||
| let private forbiddenIdCharacters = [| '/'; '\\'; '?'; '#' |] | ||
|
|
||
| [<Literal>] | ||
| let private MaxIdLength = 255 | ||
|
|
||
| let private ensureId (parameterName : string) (id : string) = | ||
| if String.IsNullOrWhiteSpace id then | ||
| invalidArg parameterName "The id must not be empty." | ||
|
|
||
| if id.IndexOfAny forbiddenIdCharacters >= 0 then | ||
| invalidArg parameterName $"The id '{id}' must not contain '/', '\\', '?' or '#'." | ||
|
|
||
| // Data Explorer refuses an id that ends in a space (ValidCosmosDbIdDescription in src/Utils/ValidationUtils.ts of | ||
| // Azure/cosmos-explorer). The id is not trimmed, because then the settings would name another resource. | ||
| if id.EndsWith (" ", StringComparison.Ordinal) then | ||
| invalidArg parameterName $"The id '{id}' must not end with a space." | ||
|
|
||
| if id.Length > MaxIdLength then | ||
| invalidArg parameterName $"The id must have {MaxIdLength} characters or less, but it has {id.Length}." | ||
|
|
||
| /// <summary> | ||
| /// Creates the settings of the graph <paramref name="graph"/> in the database <paramref name="database"/> of the | ||
| /// account <paramref name="account"/> in Azure: the host <c><account>.gremlin.cosmos.azure.com</c>, the port | ||
| /// <see cref="AzurePort"/> and TLS. | ||
| /// </summary> | ||
| /// <param name="account">The name of the account, without the domain, for example <c>myaccount</c>.</param> | ||
| /// <param name="database">The id of the database.</param> | ||
| /// <param name="graph">The id of the graph.</param> | ||
| /// <param name="key">The primary or the secondary key of the account.</param> | ||
| /// <exception cref="ArgumentException"> | ||
| /// <paramref name="account"/> is not a name of a Cosmos DB account, <paramref name="database"/> or | ||
| /// <paramref name="graph"/> is not an id of a resource, or <paramref name="key"/> is empty. | ||
| /// </exception> | ||
| let azure (account : string) (database : string) (graph : string) (key : string) : CosmosGremlinConnection = | ||
| // A caller in C# can give null, and Regex.IsMatch throws for null | ||
| if | ||
| String.IsNullOrEmpty account | ||
| || not (accountName.IsMatch account) | ||
| then | ||
| invalidArg | ||
| (nameof account) | ||
| $"'{account}' is not the name of a Cosmos DB account: 3 to 44 lowercase letters, numbers and hyphens, starting with a letter or a number." | ||
|
|
||
| ensureId (nameof database) database | ||
| ensureId (nameof graph) graph | ||
|
|
||
| if String.IsNullOrWhiteSpace key then | ||
| invalidArg (nameof key) "The key must not be empty." | ||
|
|
||
| { | ||
| Host = $"{account}.gremlin.cosmos.azure.com" | ||
| Port = AzurePort | ||
| UseSsl = true | ||
| Database = database | ||
| Graph = graph | ||
| Key = key | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates the settings of the graph <paramref name="graph"/> in the database <paramref name="database"/> of the | ||
| /// local emulator: the host <c>localhost</c>, the port <see cref="EmulatorPort"/> without TLS, and | ||
| /// <see cref="EmulatorKey"/>. The Gremlin endpoint of the emulator does not accept TLS. | ||
| /// </summary> | ||
| /// <param name="database">The id of the database.</param> | ||
| /// <param name="graph">The id of the graph.</param> | ||
| /// <exception cref="ArgumentException"> | ||
| /// <paramref name="database"/> or <paramref name="graph"/> is not an id of a resource. | ||
| /// </exception> | ||
| let emulator (database : string) (graph : string) : CosmosGremlinConnection = | ||
| ensureId (nameof database) database | ||
| ensureId (nameof graph) graph | ||
|
|
||
| { | ||
| Host = "localhost" | ||
| Port = EmulatorPort | ||
| UseSsl = false | ||
| Database = database | ||
| Graph = graph | ||
| Key = EmulatorKey | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <!-- | ||
| Azure Cosmos DB for Apache Gremlin on top of FSharp.Gremlin. It holds the connection settings, and the next steps | ||
| add the dialect of Cosmos DB, its status attributes and the results of the errors that a caller handles. The | ||
| library is built step by step. Until a query runs end to end, no package is made of it. | ||
| --> | ||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <AssemblyName>$(AssemblyBaseName).Gremlin</AssemblyName> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| <Deterministic>true</Deterministic> | ||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Label="NuGet"> | ||
| <PackageId>FSharp.Azure.Cosmos.Gremlin</PackageId> | ||
| <Title>FSharp.Azure.Cosmos.Gremlin</Title> | ||
| <Summary>Typed Gremlin traversals over immutable F# records for Azure Cosmos DB for Apache Gremlin</Summary> | ||
| <Description>Connects FSharp.Gremlin to Azure Cosmos DB for Apache Gremlin</Description> | ||
| <PackageTags>F#;FSharp;Cosmos;CosmosDB;Cosmos DB;Gremlin;Graph;TinkerPop</PackageTags> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(Configuration)'=='Release'"> | ||
| <Optimize>true</Optimize> | ||
| <Tailcalls>true</Tailcalls> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="AssemblyInfo.fs" /> | ||
| <Compile Include="CosmosGremlinConnection.fs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.SourceLink.GitHub"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| </PackageReference> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Gremlin\FSharp.Gremlin.fsproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Auto-Generated by FAKE; do not edit | ||
| namespace System | ||
| open System.Reflection | ||
|
|
||
| [<assembly: AssemblyTitleAttribute("FSharp.Gremlin")>] | ||
| [<assembly: AssemblyProductAttribute("FSharp.Azure.Cosmos")>] | ||
| [<assembly: AssemblyVersionAttribute("1.2.0")>] | ||
| [<assembly: AssemblyMetadataAttribute("ReleaseDate","2026-10-01T00:00:00.0000000+02:00")>] | ||
| [<assembly: AssemblyFileVersionAttribute("1.2.0")>] | ||
| [<assembly: AssemblyInformationalVersionAttribute("1.2.0")>] | ||
| [<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>] | ||
| [<assembly: AssemblyMetadataAttribute("GitHash","210cf041a0ce44fcc5a5df369550a77a1f75d436")>] | ||
| do () | ||
|
|
||
| module internal AssemblyVersionInformation = | ||
| let [<Literal>] AssemblyTitle = "FSharp.Gremlin" | ||
| let [<Literal>] AssemblyProduct = "FSharp.Azure.Cosmos" | ||
| let [<Literal>] AssemblyVersion = "1.2.0" | ||
| let [<Literal>] AssemblyMetadata_ReleaseDate = "2026-10-01T00:00:00.0000000+02:00" | ||
| let [<Literal>] AssemblyFileVersion = "1.2.0" | ||
| let [<Literal>] AssemblyInformationalVersion = "1.2.0" | ||
| let [<Literal>] AssemblyMetadata_ReleaseChannel = "release" | ||
| let [<Literal>] AssemblyMetadata_GitHash = "210cf041a0ce44fcc5a5df369550a77a1f75d436" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| namespace FSharp.Gremlin | ||
|
|
||
| open System | ||
|
|
||
| /// <summary> | ||
| /// Sets the label of the vertices or the edges of a record type. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Without this attribute, the label is the name of the type. ExRam.Gremlinq writes the same label. Thus a graph that | ||
| /// ExRam.Gremlinq wrote keeps its labels. | ||
| /// </remarks> | ||
| [<Sealed; AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Struct, AllowMultiple = false)>] | ||
| type LabelAttribute (label : string) = | ||
| inherit Attribute () | ||
|
|
||
| /// The label of the vertices or the edges of the type. | ||
| member _.Label = label | ||
|
|
||
| /// <summary> | ||
| /// Marks the field of a vertex record that holds the partition key of the vertex. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// A graph of Azure Cosmos DB has one partition key property, which its container defines. The client writes that | ||
| /// property of a new vertex from the marked field. A record without this attribute uses the field whose name in the | ||
| /// graph is the name of the partition key property. | ||
| /// </remarks> | ||
| [<Sealed; AttributeUsage(AttributeTargets.Property, AllowMultiple = false)>] | ||
| type PartitionKeyAttribute () = | ||
| inherit Attribute () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <!-- | ||
| The core of the Gremlin libraries. It does not depend on a provider. It holds the graph model of F# records, and | ||
| the next steps add the steps of a traversal, the Groovy writer, the wire formats and the typed queries. | ||
| FSharp.Azure.Cosmos.Gremlin adds Azure Cosmos DB for Apache Gremlin. The library is built step by step. Until a | ||
| query runs end to end, no package is made of it. | ||
| --> | ||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <AssemblyName>FSharp.Gremlin</AssemblyName> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| <Deterministic>true</Deterministic> | ||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Label="NuGet"> | ||
| <PackageId>FSharp.Gremlin</PackageId> | ||
| <Title>FSharp.Gremlin</Title> | ||
| <Summary>Typed Gremlin traversals over immutable F# records</Summary> | ||
| <Description>Provides typed Gremlin traversals over immutable F# records, with meta-properties and System.Text.Json serialization</Description> | ||
| <PackageTags>F#;FSharp;Gremlin;Graph;TinkerPop;Apache TinkerPop</PackageTags> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup Condition="'$(Configuration)'=='Release'"> | ||
| <Optimize>true</Optimize> | ||
| <Tailcalls>true</Tailcalls> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="AssemblyInfo.fs" /> | ||
| <Compile Include="Attributes.fs" /> | ||
| <Compile Include="VertexProperty.fs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.SourceLink.GitHub"> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| </PackageReference> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.