diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 34c6d1b5..0f4c3462 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -12,6 +12,8 @@ ```text / +├── src/Cosmos.Json/ – System.Text.Json converters (FSharp.Azure.Cosmos.Json), no Azure Cosmos DB SDK +│ └── JsonConverters.fs – `TimeSpanTicksConverter`, which writes a `TimeSpan` as a number of ticks ├── src/Cosmos/ – main library (FSharp.Azure.Cosmos) │ ├── SubStatusCodes.fs – documented Cosmos DB sub-status codes │ ├── Cosmos.fs – core types and container extensions diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fe536af..b620b525 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -* `TimeSpanTicksConverter`, a `System.Text.Json` converter that writes a `TimeSpan` as a JSON number of ticks. Cosmos DB sorts and compares a number in time order, but not the text that `System.Text.Json` writes (`"2.00:00:00"` sorts after `"10.00:00:00"`). The converter also reads that text, so old documents stay readable. See [How To store a duration](https://fsprojects.github.io/FSharp.Azure.Cosmos/How_Tos/Store_Durations.html) +* The package `FSharp.Azure.Cosmos.Json`, which contains the `System.Text.Json` converters. It does not use the Azure Cosmos DB SDK. Thus a project that does not reference the SDK can use the converters, for example a client of the API for Gremlin. `FSharp.Azure.Cosmos` depends on this package +* `TimeSpanTicksConverter` in the package `FSharp.Azure.Cosmos.Json`, a `System.Text.Json` converter that writes a `TimeSpan` as a JSON number of ticks. Cosmos DB sorts and compares a number in time order, but not the text that `System.Text.Json` writes (`"2.00:00:00"` sorts after `"10.00:00:00"`). The converter also reads that text, so old documents stay readable. See [How To store a duration](https://fsprojects.github.io/FSharp.Azure.Cosmos/How_Tos/Store_Durations.html) ### Changed * BREAKING: the package targets `net10.0` only and no longer supports `net8.0`, which makes this a major release diff --git a/FSharp.Azure.Cosmos.slnf b/FSharp.Azure.Cosmos.slnf index 1a0488cc..5b8c9ed8 100644 --- a/FSharp.Azure.Cosmos.slnf +++ b/FSharp.Azure.Cosmos.slnf @@ -2,6 +2,7 @@ "solution": { "path": "FSharp.Azure.Cosmos.slnx", "projects": [ + "src\\Cosmos.Json\\FSharp.Azure.Cosmos.Json.fsproj", "src\\Cosmos\\FSharp.Azure.Cosmos.fsproj", "tests\\Cosmos.Tests.Infrastructure\\FSharp.Azure.Cosmos.Tests.Infrastructure.fsproj", "tests\\Cosmos.Tests\\FSharp.Azure.Cosmos.Tests.fsproj" diff --git a/FSharp.Azure.Cosmos.slnx b/FSharp.Azure.Cosmos.slnx index 4ec89bbd..5d0c960a 100644 --- a/FSharp.Azure.Cosmos.slnx +++ b/FSharp.Azure.Cosmos.slnx @@ -10,6 +10,7 @@ + diff --git a/README.md b/README.md index 504fa70c..ea01524d 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ GitHub Actions | Package | Stable | Prerelease --- | --- | --- FSharp.Azure.Cosmos | [![NuGet Badge](https://img.shields.io/nuget/v/FSharp.Azure.Cosmos.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos/) | [![NuGet Badge](https://img.shields.io/nuget/vpre/FSharp.Azure.Cosmos.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos/) +FSharp.Azure.Cosmos.Json | [![NuGet Badge](https://img.shields.io/nuget/v/FSharp.Azure.Cosmos.Json.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos.Json/) | [![NuGet Badge](https://img.shields.io/nuget/vpre/FSharp.Azure.Cosmos.Json.svg)](https://www.nuget.org/packages/FSharp.Azure.Cosmos.Json/) --- diff --git a/docsSrc/How_Tos/Store_Durations.md b/docsSrc/How_Tos/Store_Durations.md index 276f478e..e9b665bc 100644 --- a/docsSrc/How_Tos/Store_Durations.md +++ b/docsSrc/How_Tos/Store_Durations.md @@ -14,6 +14,10 @@ after both. A query with `ORDER BY` or with `>` on such a field gives the wrong `TimeSpanTicksConverter` writes the number of ticks instead. One tick is 100 nanoseconds. Cosmos DB sorts and compares a number in time order. +The converter is in the package `FSharp.Azure.Cosmos.Json`. `FSharp.Azure.Cosmos` depends on that package, thus a +project that references `FSharp.Azure.Cosmos` has the converter too. A project that does not use the Azure Cosmos DB +SDK can reference `FSharp.Azure.Cosmos.Json` alone. + ## Use the converter Add the converter to the options of System.Text.Json. Then give the options to the client. The camel case naming diff --git a/src/Cosmos.Json/AssemblyInfo.fs b/src/Cosmos.Json/AssemblyInfo.fs new file mode 100644 index 00000000..d0f8cd95 --- /dev/null +++ b/src/Cosmos.Json/AssemblyInfo.fs @@ -0,0 +1,23 @@ +// Auto-Generated by FAKE; do not edit +namespace System +open System.Reflection + +[] +[] +[] +[] +[] +[] +[] +[] +do () + +module internal AssemblyVersionInformation = + let [] AssemblyTitle = "FSharp.Azure.Cosmos.Json" + let [] AssemblyProduct = "FSharp.Azure.Cosmos" + let [] AssemblyVersion = "1.2.0" + let [] AssemblyMetadata_ReleaseDate = "2026-10-01T00:00:00.0000000+02:00" + let [] AssemblyFileVersion = "1.2.0" + let [] AssemblyInformationalVersion = "1.2.0" + let [] AssemblyMetadata_ReleaseChannel = "release" + let [] AssemblyMetadata_GitHash = "210cf041a0ce44fcc5a5df369550a77a1f75d436" diff --git a/src/Cosmos.Json/FSharp.Azure.Cosmos.Json.fsproj b/src/Cosmos.Json/FSharp.Azure.Cosmos.Json.fsproj new file mode 100644 index 00000000..d08d78d0 --- /dev/null +++ b/src/Cosmos.Json/FSharp.Azure.Cosmos.Json.fsproj @@ -0,0 +1,40 @@ + + + + + net10.0 + $(AssemblyBaseName).Json + true + true + + + + FSharp.Azure.Cosmos.Json + FSharp.Azure.Cosmos.Json + System.Text.Json converters for the values that Azure Cosmos DB stores + Provides System.Text.Json converters that write a value in a form that Azure Cosmos DB sorts and compares in the correct order, for example a TimeSpan as a number of ticks + F#;FSharp;Cosmos;CosmosDB;Cosmos DB;System.Text.Json;JSON;Converter + + + + true + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/src/Cosmos/JsonConverters.fs b/src/Cosmos.Json/JsonConverters.fs similarity index 100% rename from src/Cosmos/JsonConverters.fs rename to src/Cosmos.Json/JsonConverters.fs diff --git a/src/Cosmos/FSharp.Azure.Cosmos.fsproj b/src/Cosmos/FSharp.Azure.Cosmos.fsproj index 0c380fef..aef46979 100644 --- a/src/Cosmos/FSharp.Azure.Cosmos.fsproj +++ b/src/Cosmos/FSharp.Azure.Cosmos.fsproj @@ -26,7 +26,6 @@ - @@ -49,4 +48,8 @@ + + + +