diff --git a/.gitattributes b/.gitattributes index 6c0b1a83..90a9845d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,9 @@ # Code generated from the blueprint by the codegen. -output/csharp/src/Seam/Api/** linguist-generated -output/csharp/src/Seam/Model/** linguist-generated -output/csharp/src/Seam/Seam.csproj linguist-generated +src/Seam/Api/** linguist-generated +src/Seam/Model/** linguist-generated # Static, schema-independent sources kept alongside the generated code. -output/csharp/src/Seam/Model/AsbtractModelSchema.cs -linguist-generated -output/csharp/src/Seam/Model/SafeStringEnumConverter.cs -linguist-generated +src/Seam/Model/AsbtractModelSchema.cs -linguist-generated +src/Seam/Model/SafeStringEnumConverter.cs -linguist-generated diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index a1a7a5d3..37255cec 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -37,4 +37,4 @@ runs: - name: Restore dependencies if: inputs.install_dependencies == 'true' shell: bash - run: dotnet restore ./output/csharp + run: dotnet restore ./Seam.sln diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index e9ae5dbb..c72fae71 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -30,8 +30,8 @@ jobs: uses: tj-actions/changed-files@v44 with: files: | - output/csharp/src/Seam/Api/** - output/csharp/src/Seam/Model/** + src/Seam/Api/** + src/Seam/Model/** merge: name: Merge runs-on: ubuntu-latest diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 255dd128..7ef8ead3 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -37,6 +37,8 @@ jobs: install_dependencies: 'false' - name: Normalize package-lock.json run: npm install + - name: Restore tools + run: dotnet tool restore - name: Generate code run: npm run generate - name: Commit diff --git a/README.md b/README.md index 470ffe7a..f1c18324 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ and dispatches the [Version](.github/workflows/version.yml) workflow. Run the [Version](.github/workflows/version.yml) workflow with the version to cut. It runs `npm version`, which bumps the `version` field in `package.json`, -regenerates `Seam.csproj` with that version, creates a signed `v*` git tag +injects that version into `Seam.csproj`, creates a signed `v*` git tag and pushes it. Pushing the tag triggers the [Publish](.github/workflows/publish.yml) workflow, which packs the library with `dotnet pack` and pushes the @@ -207,12 +207,11 @@ package to [NuGet](https://www.nuget.org/packages/Seam) and GitHub Packages. > The version lives in `package.json`, the development manifest that -> drives the codegen, and is injected into `Seam.csproj` by -> `src/generate-csproj.ts`. -> The injection runs from `src/version.ts`, wired to the `version` -> lifecycle script, which npm runs after the bump but before the commit, -> so the updated project file is part of the tagged commit and MSBuild -> surfaces the version at runtime through +> drives the codegen. +> `version.ts`, wired to the `version` lifecycle script, injects it +> into the `` element of `Seam.csproj`, which npm runs after the +> bump but before the commit, so the updated project file is part of the +> tagged commit and MSBuild surfaces the version at runtime through > `AssemblyInformationalVersionAttribute`. > Never edit the version in `Seam.csproj` by hand. diff --git a/output/csharp/csharp-testing.sln b/Seam.sln similarity index 85% rename from output/csharp/csharp-testing.sln rename to Seam.sln index 9cf67046..cbc8d6ff 100644 --- a/output/csharp/csharp-testing.sln +++ b/Seam.sln @@ -5,9 +5,11 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E1444EB3-69DB-4DC7-B1DA-798B74419077}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{7C2E8F1A-4B3D-4C5E-9A6F-1D2E3F4A5B6C}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seam", "src\Seam\Seam.csproj", "{9A33E809-F95A-4E65-A9F8-145A49A16EBC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seam.Test", "src\Seam.Test\Seam.Test.csproj", "{B6EDC1FF-9838-4997-B98E-62B768430DF3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Seam.Test", "test\Seam.Test\Seam.Test.csproj", "{B6EDC1FF-9838-4997-B98E-62B768430DF3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -29,6 +31,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {9A33E809-F95A-4E65-A9F8-145A49A16EBC} = {E1444EB3-69DB-4DC7-B1DA-798B74419077} - {B6EDC1FF-9838-4997-B98E-62B768430DF3} = {E1444EB3-69DB-4DC7-B1DA-798B74419077} + {B6EDC1FF-9838-4997-B98E-62B768430DF3} = {7C2E8F1A-4B3D-4C5E-9A6F-1D2E3F4A5B6C} EndGlobalSection EndGlobal diff --git a/codegen/lib/class-model.ts b/codegen/lib/class-model.ts index 3fcb59cd..13d64f9f 100644 --- a/codegen/lib/class-model.ts +++ b/codegen/lib/class-model.ts @@ -83,7 +83,7 @@ export interface CsUnion { export type CsDecl = CsClass | CsUnion -// A generated model file (output/csharp/src/Seam/Model/.cs): one or more +// A generated model file (src/Seam/Model/.cs): one or more // top-level declarations (the main type first, then sibling classes spawned by // inline-object properties). export interface CsModelFile { @@ -119,7 +119,7 @@ export interface CsRoute { obsoleteMessage?: string } -// A generated Api file (output/csharp/src/Seam/Api/.cs). +// A generated Api file (src/Seam/Api/.cs). export interface CsApiFile { className: string routes: CsRoute[] diff --git a/codegen/lib/csharp.ts b/codegen/lib/csharp.ts index 1b6e293b..d35e4d82 100644 --- a/codegen/lib/csharp.ts +++ b/codegen/lib/csharp.ts @@ -9,7 +9,7 @@ import { buildModelFile, } from './build-model.js' -const outputRoot = 'output/csharp/src/Seam' +const outputRoot = 'src/Seam' // Resource types that are emitted as discriminated unions rather than plain // model classes. @@ -21,8 +21,8 @@ const apiClassName = (path: string): string => pascalCase(path.split('/').filter(Boolean).reverse().join('_')) // Metalsmith plugin that generates the blueprint-derived C# SDK files: the Api -// route classes (output/csharp/src/Seam/Api/*.cs) and the resource models -// (output/csharp/src/Seam/Model/*.cs). Static, schema-independent files (the +// route classes (src/Seam/Api/*.cs) and the resource models +// (src/Seam/Model/*.cs). Static, schema-independent files (the // Client/* runtime, the static Model helpers, the .sln, the test project) are // normal committed package source and are intentionally NOT generated here. // diff --git a/justfile b/justfile index cddb9e88..7e39b832 100644 --- a/justfile +++ b/justfile @@ -1,15 +1,15 @@ # Build the package build: - dotnet pack --configuration Release --output pkg ./output/csharp/src/Seam + dotnet pack --configuration Release --output pkg ./src/Seam # Run the tests test framework="": - dotnet test ./output/csharp {{ if framework == "" { "" } else { "--framework " + framework } }} + dotnet test ./Seam.sln {{ if framework == "" { "" } else { "--framework " + framework } }} # Lint lint: - dotnet csharpier --check ./output/csharp + dotnet csharpier --check ./src ./test # Format format: - dotnet csharpier ./output/csharp + dotnet csharpier ./src ./test diff --git a/output/csharp/.gitignore b/output/csharp/.gitignore deleted file mode 100644 index 1746e326..00000000 --- a/output/csharp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bin -obj diff --git a/output/csharp/src/Seam/README.md b/output/csharp/src/Seam/README.md deleted file mode 100644 index 3afd5453..00000000 --- a/output/csharp/src/Seam/README.md +++ /dev/null @@ -1,124 +0,0 @@ -# Seam C# - -## Usage - -```csharp -using Seam.Client; - -var seam = new SeamClient(apiToken: "YOUR_API_KEY"); - -var myDevices = seam.Devices.List(); - -Console.WriteLine("First Device Name: " + myDevices[0].Properties.Name); - -var accessCode = seam.AccessCodes.Create(deviceId: myDevices[0].DeviceId, code: "1234"); -``` - -### Setting a value to null - -The Seam API distinguishes three states for an updatable parameter: -omitted (leave the stored value unchanged), null (unset the stored value), -and a value (set it). - -C#'s `null` means omitted. -The SDK removes `null` parameters from the request entirely, -so passing `null` never unsets a value. -To unset a value, pass the `Null.Value` sentinel, -which the SDK sends as JSON `null` in request bodies -and as an empty value in query strings: - -```csharp -// Omits custom_metadata, leaving the stored metadata unchanged. -seam.Devices.Update(deviceId: deviceId, customMetadata: null); - -// Unsets the sync key of the stored metadata. -seam.Devices.Update( - deviceId: deviceId, - customMetadata: new Dictionary { ["sync"] = Null.Value } -); -``` - -Only pass `Null.Value` where the Seam API documents a value as nullable. -A parameter typed as a specific C# type, e.g. `string?`, does not accept the -sentinel: pass it wherever a parameter is typed `object`, and to the URL search -params serializer below. - -## Advanced Usage - -### Setting the request timeout - -Requests time out after 30 seconds by default. -Pass the `timeout` option, in milliseconds, to override this: - -```csharp -var seam = new SeamClient(apiToken: "YOUR_API_KEY", timeout: 60000); -``` - -The default may also be changed for every client at once: - -```csharp -GlobalSeamRequestConfiguration.Instance.Timeout = 60000; -``` - -### Serializing URL search params - -The Seam API parses URL search params as complex types. -The SDK serializes the params of every endpoint -the Seam API prefers to receive as a GET or DELETE this way. -If you call the API with your own HTTP client, -`StrictUrlSearchParamsSerializer` is exported for that purpose. -The `_strict=true` parameter is added to any non-empty query -so the Seam API uses strict, schema-aware parsing. -A query with no serializable parameters remains empty. - -```csharp -using Seam.Client; - -var query = StrictUrlSearchParamsSerializer.Serialize( - new Dictionary { ["device_ids"] = new[] { "device1", "device2" } } -); - -using var client = new HttpClient(); -client.DefaultRequestHeaders.Add("Authorization", "Bearer your-api-key"); - -var devices = await client.GetStringAsync($"https://connect.getseam.com/devices/list?{query}"); -``` - -The serialization defines the name and value of each search param, -where every value is a string. -`UrlSearchParams` holds those pairs and renders the query string, -as [URLSearchParams] does for the [reference implementation]: - -```csharp -using Seam.Client; - -var searchParams = new UrlSearchParams(); - -StrictUrlSearchParamsSerializer.Update( - searchParams, - new Dictionary { ["device_ids"] = new[] { "device1", "device2" } } -); - -searchParams.Select(pair => (pair.Key, pair.Value)).ToList(); -// => [("device_ids", "device1"), ("device_ids", "device2"), ("_strict", "true")] - -searchParams.ToString(); -// => "device_ids=device1&device_ids=device2&_strict=true" -``` - -Pass either the query string or the pairs to your HTTP client. -A client may percent-encode a few characters differently -than `URLSearchParams` does, -which the Seam API reads as the same params either way. - -A parameter set to `null` is omitted, -while a parameter set to `Null.Value` is serialized to an empty value, -which the Seam API reads as null, -as described in [Setting a value to null](#setting-a-value-to-null). -A parameter that cannot be represented throws an `UnserializableParamError`. - -The Seam API parses these params with the corresponding [parser]. - -[URLSearchParams]: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams -[reference implementation]: https://github.com/seamapi/url-search-params-serializer -[parser]: https://github.com/seamapi/url-search-params-parser diff --git a/package.json b/package.json index 4a9d6e60..1f972e7b 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,10 @@ "private": true, "license": "MIT", "scripts": { - "version": "tsx src/version.ts", + "version": "tsx ./version.ts", "postversion": "git push --follow-tags", "generate": "tsx codegen/smith.ts", - "postgenerate": "tsx src/postgenerate.ts", - "generate:csproj": "tsx src/generate-csproj.ts", + "postgenerate": "just format", "typecheck": "tsc", "lint": "eslint .", "postlint": "prettier --check --ignore-path .gitignore --ignore-path .prettierignore .", diff --git a/output/csharp/src/Seam/Api/AccessCodes.cs b/src/Seam/Api/AccessCodes.cs similarity index 100% rename from output/csharp/src/Seam/Api/AccessCodes.cs rename to src/Seam/Api/AccessCodes.cs diff --git a/output/csharp/src/Seam/Api/AccessGrants.cs b/src/Seam/Api/AccessGrants.cs similarity index 100% rename from output/csharp/src/Seam/Api/AccessGrants.cs rename to src/Seam/Api/AccessGrants.cs diff --git a/output/csharp/src/Seam/Api/AccessGroupsAcs.cs b/src/Seam/Api/AccessGroupsAcs.cs similarity index 100% rename from output/csharp/src/Seam/Api/AccessGroupsAcs.cs rename to src/Seam/Api/AccessGroupsAcs.cs diff --git a/output/csharp/src/Seam/Api/AccessMethods.cs b/src/Seam/Api/AccessMethods.cs similarity index 100% rename from output/csharp/src/Seam/Api/AccessMethods.cs rename to src/Seam/Api/AccessMethods.cs diff --git a/output/csharp/src/Seam/Api/ActionAttempts.cs b/src/Seam/Api/ActionAttempts.cs similarity index 100% rename from output/csharp/src/Seam/Api/ActionAttempts.cs rename to src/Seam/Api/ActionAttempts.cs diff --git a/output/csharp/src/Seam/Api/ClientSessions.cs b/src/Seam/Api/ClientSessions.cs similarity index 100% rename from output/csharp/src/Seam/Api/ClientSessions.cs rename to src/Seam/Api/ClientSessions.cs diff --git a/output/csharp/src/Seam/Api/ConnectWebviews.cs b/src/Seam/Api/ConnectWebviews.cs similarity index 100% rename from output/csharp/src/Seam/Api/ConnectWebviews.cs rename to src/Seam/Api/ConnectWebviews.cs diff --git a/output/csharp/src/Seam/Api/ConnectedAccounts.cs b/src/Seam/Api/ConnectedAccounts.cs similarity index 100% rename from output/csharp/src/Seam/Api/ConnectedAccounts.cs rename to src/Seam/Api/ConnectedAccounts.cs diff --git a/output/csharp/src/Seam/Api/CredentialsAcs.cs b/src/Seam/Api/CredentialsAcs.cs similarity index 100% rename from output/csharp/src/Seam/Api/CredentialsAcs.cs rename to src/Seam/Api/CredentialsAcs.cs diff --git a/output/csharp/src/Seam/Api/Customers.cs b/src/Seam/Api/Customers.cs similarity index 100% rename from output/csharp/src/Seam/Api/Customers.cs rename to src/Seam/Api/Customers.cs diff --git a/output/csharp/src/Seam/Api/DailyProgramsThermostats.cs b/src/Seam/Api/DailyProgramsThermostats.cs similarity index 100% rename from output/csharp/src/Seam/Api/DailyProgramsThermostats.cs rename to src/Seam/Api/DailyProgramsThermostats.cs diff --git a/output/csharp/src/Seam/Api/Devices.cs b/src/Seam/Api/Devices.cs similarity index 100% rename from output/csharp/src/Seam/Api/Devices.cs rename to src/Seam/Api/Devices.cs diff --git a/output/csharp/src/Seam/Api/EncodersAcs.cs b/src/Seam/Api/EncodersAcs.cs similarity index 100% rename from output/csharp/src/Seam/Api/EncodersAcs.cs rename to src/Seam/Api/EncodersAcs.cs diff --git a/output/csharp/src/Seam/Api/EntrancesAcs.cs b/src/Seam/Api/EntrancesAcs.cs similarity index 100% rename from output/csharp/src/Seam/Api/EntrancesAcs.cs rename to src/Seam/Api/EntrancesAcs.cs diff --git a/output/csharp/src/Seam/Api/Events.cs b/src/Seam/Api/Events.cs similarity index 100% rename from output/csharp/src/Seam/Api/Events.cs rename to src/Seam/Api/Events.cs diff --git a/output/csharp/src/Seam/Api/InstantKeys.cs b/src/Seam/Api/InstantKeys.cs similarity index 100% rename from output/csharp/src/Seam/Api/InstantKeys.cs rename to src/Seam/Api/InstantKeys.cs diff --git a/output/csharp/src/Seam/Api/Locks.cs b/src/Seam/Api/Locks.cs similarity index 100% rename from output/csharp/src/Seam/Api/Locks.cs rename to src/Seam/Api/Locks.cs diff --git a/output/csharp/src/Seam/Api/NoiseSensors.cs b/src/Seam/Api/NoiseSensors.cs similarity index 100% rename from output/csharp/src/Seam/Api/NoiseSensors.cs rename to src/Seam/Api/NoiseSensors.cs diff --git a/output/csharp/src/Seam/Api/NoiseThresholdsNoiseSensors.cs b/src/Seam/Api/NoiseThresholdsNoiseSensors.cs similarity index 100% rename from output/csharp/src/Seam/Api/NoiseThresholdsNoiseSensors.cs rename to src/Seam/Api/NoiseThresholdsNoiseSensors.cs diff --git a/output/csharp/src/Seam/Api/Phones.cs b/src/Seam/Api/Phones.cs similarity index 100% rename from output/csharp/src/Seam/Api/Phones.cs rename to src/Seam/Api/Phones.cs diff --git a/output/csharp/src/Seam/Api/SchedulesThermostats.cs b/src/Seam/Api/SchedulesThermostats.cs similarity index 100% rename from output/csharp/src/Seam/Api/SchedulesThermostats.cs rename to src/Seam/Api/SchedulesThermostats.cs diff --git a/output/csharp/src/Seam/Api/SimulateAccessCodes.cs b/src/Seam/Api/SimulateAccessCodes.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulateAccessCodes.cs rename to src/Seam/Api/SimulateAccessCodes.cs diff --git a/output/csharp/src/Seam/Api/SimulateConnectedAccounts.cs b/src/Seam/Api/SimulateConnectedAccounts.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulateConnectedAccounts.cs rename to src/Seam/Api/SimulateConnectedAccounts.cs diff --git a/output/csharp/src/Seam/Api/SimulateDevices.cs b/src/Seam/Api/SimulateDevices.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulateDevices.cs rename to src/Seam/Api/SimulateDevices.cs diff --git a/output/csharp/src/Seam/Api/SimulateEncodersAcs.cs b/src/Seam/Api/SimulateEncodersAcs.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulateEncodersAcs.cs rename to src/Seam/Api/SimulateEncodersAcs.cs diff --git a/output/csharp/src/Seam/Api/SimulateLocks.cs b/src/Seam/Api/SimulateLocks.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulateLocks.cs rename to src/Seam/Api/SimulateLocks.cs diff --git a/output/csharp/src/Seam/Api/SimulateNoiseSensors.cs b/src/Seam/Api/SimulateNoiseSensors.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulateNoiseSensors.cs rename to src/Seam/Api/SimulateNoiseSensors.cs diff --git a/output/csharp/src/Seam/Api/SimulatePhones.cs b/src/Seam/Api/SimulatePhones.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulatePhones.cs rename to src/Seam/Api/SimulatePhones.cs diff --git a/output/csharp/src/Seam/Api/SimulateThermostats.cs b/src/Seam/Api/SimulateThermostats.cs similarity index 100% rename from output/csharp/src/Seam/Api/SimulateThermostats.cs rename to src/Seam/Api/SimulateThermostats.cs diff --git a/output/csharp/src/Seam/Api/Spaces.cs b/src/Seam/Api/Spaces.cs similarity index 100% rename from output/csharp/src/Seam/Api/Spaces.cs rename to src/Seam/Api/Spaces.cs diff --git a/output/csharp/src/Seam/Api/SystemsAcs.cs b/src/Seam/Api/SystemsAcs.cs similarity index 100% rename from output/csharp/src/Seam/Api/SystemsAcs.cs rename to src/Seam/Api/SystemsAcs.cs diff --git a/output/csharp/src/Seam/Api/Thermostats.cs b/src/Seam/Api/Thermostats.cs similarity index 100% rename from output/csharp/src/Seam/Api/Thermostats.cs rename to src/Seam/Api/Thermostats.cs diff --git a/output/csharp/src/Seam/Api/UnmanagedAccessCodes.cs b/src/Seam/Api/UnmanagedAccessCodes.cs similarity index 100% rename from output/csharp/src/Seam/Api/UnmanagedAccessCodes.cs rename to src/Seam/Api/UnmanagedAccessCodes.cs diff --git a/output/csharp/src/Seam/Api/UnmanagedAccessGrants.cs b/src/Seam/Api/UnmanagedAccessGrants.cs similarity index 100% rename from output/csharp/src/Seam/Api/UnmanagedAccessGrants.cs rename to src/Seam/Api/UnmanagedAccessGrants.cs diff --git a/output/csharp/src/Seam/Api/UnmanagedAccessMethods.cs b/src/Seam/Api/UnmanagedAccessMethods.cs similarity index 100% rename from output/csharp/src/Seam/Api/UnmanagedAccessMethods.cs rename to src/Seam/Api/UnmanagedAccessMethods.cs diff --git a/output/csharp/src/Seam/Api/UnmanagedDevices.cs b/src/Seam/Api/UnmanagedDevices.cs similarity index 100% rename from output/csharp/src/Seam/Api/UnmanagedDevices.cs rename to src/Seam/Api/UnmanagedDevices.cs diff --git a/output/csharp/src/Seam/Api/UnmanagedUserIdentities.cs b/src/Seam/Api/UnmanagedUserIdentities.cs similarity index 100% rename from output/csharp/src/Seam/Api/UnmanagedUserIdentities.cs rename to src/Seam/Api/UnmanagedUserIdentities.cs diff --git a/output/csharp/src/Seam/Api/UserIdentities.cs b/src/Seam/Api/UserIdentities.cs similarity index 100% rename from output/csharp/src/Seam/Api/UserIdentities.cs rename to src/Seam/Api/UserIdentities.cs diff --git a/output/csharp/src/Seam/Api/UsersAcs.cs b/src/Seam/Api/UsersAcs.cs similarity index 100% rename from output/csharp/src/Seam/Api/UsersAcs.cs rename to src/Seam/Api/UsersAcs.cs diff --git a/output/csharp/src/Seam/Api/Webhooks.cs b/src/Seam/Api/Webhooks.cs similarity index 100% rename from output/csharp/src/Seam/Api/Webhooks.cs rename to src/Seam/Api/Webhooks.cs diff --git a/output/csharp/src/Seam/Api/Workspaces.cs b/src/Seam/Api/Workspaces.cs similarity index 100% rename from output/csharp/src/Seam/Api/Workspaces.cs rename to src/Seam/Api/Workspaces.cs diff --git a/output/csharp/src/Seam/Client/ApiResponse.cs b/src/Seam/Client/ApiResponse.cs similarity index 100% rename from output/csharp/src/Seam/Client/ApiResponse.cs rename to src/Seam/Client/ApiResponse.cs diff --git a/output/csharp/src/Seam/Client/ClientUtils.cs b/src/Seam/Client/ClientUtils.cs similarity index 100% rename from output/csharp/src/Seam/Client/ClientUtils.cs rename to src/Seam/Client/ClientUtils.cs diff --git a/output/csharp/src/Seam/Client/ExceptionFactory.cs b/src/Seam/Client/ExceptionFactory.cs similarity index 100% rename from output/csharp/src/Seam/Client/ExceptionFactory.cs rename to src/Seam/Client/ExceptionFactory.cs diff --git a/output/csharp/src/Seam/Client/GlobalSeamRequestConfiguration.cs b/src/Seam/Client/GlobalSeamRequestConfiguration.cs similarity index 100% rename from output/csharp/src/Seam/Client/GlobalSeamRequestConfiguration.cs rename to src/Seam/Client/GlobalSeamRequestConfiguration.cs diff --git a/output/csharp/src/Seam/Client/HttpMethod.cs b/src/Seam/Client/HttpMethod.cs similarity index 100% rename from output/csharp/src/Seam/Client/HttpMethod.cs rename to src/Seam/Client/HttpMethod.cs diff --git a/output/csharp/src/Seam/Client/IAsynchronousSeam.cs b/src/Seam/Client/IAsynchronousSeam.cs similarity index 100% rename from output/csharp/src/Seam/Client/IAsynchronousSeam.cs rename to src/Seam/Client/IAsynchronousSeam.cs diff --git a/output/csharp/src/Seam/Client/IReadableSeamRequestConfiguration.cs b/src/Seam/Client/IReadableSeamRequestConfiguration.cs similarity index 100% rename from output/csharp/src/Seam/Client/IReadableSeamRequestConfiguration.cs rename to src/Seam/Client/IReadableSeamRequestConfiguration.cs diff --git a/output/csharp/src/Seam/Client/ISynchronousSeam.cs b/src/Seam/Client/ISynchronousSeam.cs similarity index 100% rename from output/csharp/src/Seam/Client/ISynchronousSeam.cs rename to src/Seam/Client/ISynchronousSeam.cs diff --git a/output/csharp/src/Seam/Client/Multimap.cs b/src/Seam/Client/Multimap.cs similarity index 100% rename from output/csharp/src/Seam/Client/Multimap.cs rename to src/Seam/Client/Multimap.cs diff --git a/output/csharp/src/Seam/Client/Null.cs b/src/Seam/Client/Null.cs similarity index 100% rename from output/csharp/src/Seam/Client/Null.cs rename to src/Seam/Client/Null.cs diff --git a/output/csharp/src/Seam/Client/RequestOptions.cs b/src/Seam/Client/RequestOptions.cs similarity index 100% rename from output/csharp/src/Seam/Client/RequestOptions.cs rename to src/Seam/Client/RequestOptions.cs diff --git a/output/csharp/src/Seam/Client/RetryConfiguration.cs b/src/Seam/Client/RetryConfiguration.cs similarity index 100% rename from output/csharp/src/Seam/Client/RetryConfiguration.cs rename to src/Seam/Client/RetryConfiguration.cs diff --git a/output/csharp/src/Seam/Client/Seam.cs b/src/Seam/Client/Seam.cs similarity index 100% rename from output/csharp/src/Seam/Client/Seam.cs rename to src/Seam/Client/Seam.cs diff --git a/output/csharp/src/Seam/Client/SeamException.cs b/src/Seam/Client/SeamException.cs similarity index 100% rename from output/csharp/src/Seam/Client/SeamException.cs rename to src/Seam/Client/SeamException.cs diff --git a/output/csharp/src/Seam/Client/SeamRequestConfiguration.cs b/src/Seam/Client/SeamRequestConfiguration.cs similarity index 100% rename from output/csharp/src/Seam/Client/SeamRequestConfiguration.cs rename to src/Seam/Client/SeamRequestConfiguration.cs diff --git a/output/csharp/src/Seam/Client/StrictUrlSearchParamsSerializer.cs b/src/Seam/Client/StrictUrlSearchParamsSerializer.cs similarity index 100% rename from output/csharp/src/Seam/Client/StrictUrlSearchParamsSerializer.cs rename to src/Seam/Client/StrictUrlSearchParamsSerializer.cs diff --git a/output/csharp/src/Seam/Client/UnserializableParamError.cs b/src/Seam/Client/UnserializableParamError.cs similarity index 100% rename from output/csharp/src/Seam/Client/UnserializableParamError.cs rename to src/Seam/Client/UnserializableParamError.cs diff --git a/output/csharp/src/Seam/Client/UrlSearchParams.cs b/src/Seam/Client/UrlSearchParams.cs similarity index 100% rename from output/csharp/src/Seam/Client/UrlSearchParams.cs rename to src/Seam/Client/UrlSearchParams.cs diff --git a/output/csharp/src/Seam/Client/UrlSearchParamsSerializer.cs b/src/Seam/Client/UrlSearchParamsSerializer.cs similarity index 100% rename from output/csharp/src/Seam/Client/UrlSearchParamsSerializer.cs rename to src/Seam/Client/UrlSearchParamsSerializer.cs diff --git a/output/csharp/src/Seam/Model/AccessCode.cs b/src/Seam/Model/AccessCode.cs similarity index 100% rename from output/csharp/src/Seam/Model/AccessCode.cs rename to src/Seam/Model/AccessCode.cs diff --git a/output/csharp/src/Seam/Model/AccessGrant.cs b/src/Seam/Model/AccessGrant.cs similarity index 100% rename from output/csharp/src/Seam/Model/AccessGrant.cs rename to src/Seam/Model/AccessGrant.cs diff --git a/output/csharp/src/Seam/Model/AccessMethod.cs b/src/Seam/Model/AccessMethod.cs similarity index 100% rename from output/csharp/src/Seam/Model/AccessMethod.cs rename to src/Seam/Model/AccessMethod.cs diff --git a/output/csharp/src/Seam/Model/AcsAccessGroup.cs b/src/Seam/Model/AcsAccessGroup.cs similarity index 100% rename from output/csharp/src/Seam/Model/AcsAccessGroup.cs rename to src/Seam/Model/AcsAccessGroup.cs diff --git a/output/csharp/src/Seam/Model/AcsCredential.cs b/src/Seam/Model/AcsCredential.cs similarity index 100% rename from output/csharp/src/Seam/Model/AcsCredential.cs rename to src/Seam/Model/AcsCredential.cs diff --git a/output/csharp/src/Seam/Model/AcsEncoder.cs b/src/Seam/Model/AcsEncoder.cs similarity index 100% rename from output/csharp/src/Seam/Model/AcsEncoder.cs rename to src/Seam/Model/AcsEncoder.cs diff --git a/output/csharp/src/Seam/Model/AcsEntrance.cs b/src/Seam/Model/AcsEntrance.cs similarity index 100% rename from output/csharp/src/Seam/Model/AcsEntrance.cs rename to src/Seam/Model/AcsEntrance.cs diff --git a/output/csharp/src/Seam/Model/AcsSystem.cs b/src/Seam/Model/AcsSystem.cs similarity index 100% rename from output/csharp/src/Seam/Model/AcsSystem.cs rename to src/Seam/Model/AcsSystem.cs diff --git a/output/csharp/src/Seam/Model/AcsUser.cs b/src/Seam/Model/AcsUser.cs similarity index 100% rename from output/csharp/src/Seam/Model/AcsUser.cs rename to src/Seam/Model/AcsUser.cs diff --git a/output/csharp/src/Seam/Model/ActionAttempt.cs b/src/Seam/Model/ActionAttempt.cs similarity index 100% rename from output/csharp/src/Seam/Model/ActionAttempt.cs rename to src/Seam/Model/ActionAttempt.cs diff --git a/output/csharp/src/Seam/Model/AsbtractModelSchema.cs b/src/Seam/Model/AsbtractModelSchema.cs similarity index 100% rename from output/csharp/src/Seam/Model/AsbtractModelSchema.cs rename to src/Seam/Model/AsbtractModelSchema.cs diff --git a/output/csharp/src/Seam/Model/Batch.cs b/src/Seam/Model/Batch.cs similarity index 100% rename from output/csharp/src/Seam/Model/Batch.cs rename to src/Seam/Model/Batch.cs diff --git a/output/csharp/src/Seam/Model/ClientSession.cs b/src/Seam/Model/ClientSession.cs similarity index 100% rename from output/csharp/src/Seam/Model/ClientSession.cs rename to src/Seam/Model/ClientSession.cs diff --git a/output/csharp/src/Seam/Model/ConnectWebview.cs b/src/Seam/Model/ConnectWebview.cs similarity index 100% rename from output/csharp/src/Seam/Model/ConnectWebview.cs rename to src/Seam/Model/ConnectWebview.cs diff --git a/output/csharp/src/Seam/Model/ConnectedAccount.cs b/src/Seam/Model/ConnectedAccount.cs similarity index 100% rename from output/csharp/src/Seam/Model/ConnectedAccount.cs rename to src/Seam/Model/ConnectedAccount.cs diff --git a/output/csharp/src/Seam/Model/CustomerPortal.cs b/src/Seam/Model/CustomerPortal.cs similarity index 100% rename from output/csharp/src/Seam/Model/CustomerPortal.cs rename to src/Seam/Model/CustomerPortal.cs diff --git a/output/csharp/src/Seam/Model/Device.cs b/src/Seam/Model/Device.cs similarity index 100% rename from output/csharp/src/Seam/Model/Device.cs rename to src/Seam/Model/Device.cs diff --git a/output/csharp/src/Seam/Model/DeviceProvider.cs b/src/Seam/Model/DeviceProvider.cs similarity index 100% rename from output/csharp/src/Seam/Model/DeviceProvider.cs rename to src/Seam/Model/DeviceProvider.cs diff --git a/output/csharp/src/Seam/Model/Event.cs b/src/Seam/Model/Event.cs similarity index 100% rename from output/csharp/src/Seam/Model/Event.cs rename to src/Seam/Model/Event.cs diff --git a/output/csharp/src/Seam/Model/InstantKey.cs b/src/Seam/Model/InstantKey.cs similarity index 100% rename from output/csharp/src/Seam/Model/InstantKey.cs rename to src/Seam/Model/InstantKey.cs diff --git a/output/csharp/src/Seam/Model/NoiseThreshold.cs b/src/Seam/Model/NoiseThreshold.cs similarity index 100% rename from output/csharp/src/Seam/Model/NoiseThreshold.cs rename to src/Seam/Model/NoiseThreshold.cs diff --git a/output/csharp/src/Seam/Model/Phone.cs b/src/Seam/Model/Phone.cs similarity index 100% rename from output/csharp/src/Seam/Model/Phone.cs rename to src/Seam/Model/Phone.cs diff --git a/output/csharp/src/Seam/Model/SafeStringEnumConverter.cs b/src/Seam/Model/SafeStringEnumConverter.cs similarity index 100% rename from output/csharp/src/Seam/Model/SafeStringEnumConverter.cs rename to src/Seam/Model/SafeStringEnumConverter.cs diff --git a/output/csharp/src/Seam/Model/Space.cs b/src/Seam/Model/Space.cs similarity index 100% rename from output/csharp/src/Seam/Model/Space.cs rename to src/Seam/Model/Space.cs diff --git a/output/csharp/src/Seam/Model/ThermostatDailyProgram.cs b/src/Seam/Model/ThermostatDailyProgram.cs similarity index 100% rename from output/csharp/src/Seam/Model/ThermostatDailyProgram.cs rename to src/Seam/Model/ThermostatDailyProgram.cs diff --git a/output/csharp/src/Seam/Model/ThermostatSchedule.cs b/src/Seam/Model/ThermostatSchedule.cs similarity index 100% rename from output/csharp/src/Seam/Model/ThermostatSchedule.cs rename to src/Seam/Model/ThermostatSchedule.cs diff --git a/output/csharp/src/Seam/Model/UnmanagedAccessCode.cs b/src/Seam/Model/UnmanagedAccessCode.cs similarity index 100% rename from output/csharp/src/Seam/Model/UnmanagedAccessCode.cs rename to src/Seam/Model/UnmanagedAccessCode.cs diff --git a/output/csharp/src/Seam/Model/UnmanagedAccessGrant.cs b/src/Seam/Model/UnmanagedAccessGrant.cs similarity index 100% rename from output/csharp/src/Seam/Model/UnmanagedAccessGrant.cs rename to src/Seam/Model/UnmanagedAccessGrant.cs diff --git a/output/csharp/src/Seam/Model/UnmanagedAccessMethod.cs b/src/Seam/Model/UnmanagedAccessMethod.cs similarity index 100% rename from output/csharp/src/Seam/Model/UnmanagedAccessMethod.cs rename to src/Seam/Model/UnmanagedAccessMethod.cs diff --git a/output/csharp/src/Seam/Model/UnmanagedDevice.cs b/src/Seam/Model/UnmanagedDevice.cs similarity index 100% rename from output/csharp/src/Seam/Model/UnmanagedDevice.cs rename to src/Seam/Model/UnmanagedDevice.cs diff --git a/output/csharp/src/Seam/Model/UnmanagedUserIdentity.cs b/src/Seam/Model/UnmanagedUserIdentity.cs similarity index 100% rename from output/csharp/src/Seam/Model/UnmanagedUserIdentity.cs rename to src/Seam/Model/UnmanagedUserIdentity.cs diff --git a/output/csharp/src/Seam/Model/UserIdentity.cs b/src/Seam/Model/UserIdentity.cs similarity index 100% rename from output/csharp/src/Seam/Model/UserIdentity.cs rename to src/Seam/Model/UserIdentity.cs diff --git a/output/csharp/src/Seam/Model/Webhook.cs b/src/Seam/Model/Webhook.cs similarity index 100% rename from output/csharp/src/Seam/Model/Webhook.cs rename to src/Seam/Model/Webhook.cs diff --git a/output/csharp/src/Seam/Model/Workspace.cs b/src/Seam/Model/Workspace.cs similarity index 100% rename from output/csharp/src/Seam/Model/Workspace.cs rename to src/Seam/Model/Workspace.cs diff --git a/output/csharp/src/Seam/Seam.csproj b/src/Seam/Seam.csproj similarity index 85% rename from output/csharp/src/Seam/Seam.csproj rename to src/Seam/Seam.csproj index 8ad7bd57..7c22047d 100644 --- a/output/csharp/src/Seam/Seam.csproj +++ b/src/Seam/Seam.csproj @@ -7,6 +7,8 @@ Seam + 1.3.0 Seam Labs, Inc. @@ -38,7 +40,7 @@ - + diff --git a/output/csharp/src/Seam/icon.png b/src/Seam/icon.png similarity index 100% rename from output/csharp/src/Seam/icon.png rename to src/Seam/icon.png diff --git a/src/generate-csproj.ts b/src/generate-csproj.ts deleted file mode 100644 index f04b8eb1..00000000 --- a/src/generate-csproj.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { readFileSync, writeFileSync } from 'node:fs' - -const { version } = JSON.parse( - readFileSync(new URL('../package.json', import.meta.url), 'utf-8'), -) - -export const csprojTemplate = (version: string, dotNetVersions: string[]) => - ` - - - - ${dotNetVersions - .map((v) => `net${v}`) - .join(';')} - enable - annotations - - Seam - - ${version} - - Seam Labs, Inc. - - Seam - - SDK for the Seam API written in C#. - - Copyright (c) 2021-2026 Seam Labs, Inc. - - seam;api;iot - - MIT - - README.md - - icon.png - - https://github.com/seamapi/csharp - - https://github.com/seamapi/csharp - - git - - true - - $(NoWarn);CS1591 - - - - - - - - - - - - - - -`.trim() - -const main = async () => { - writeFileSync( - './output/csharp/src/Seam/Seam.csproj', - csprojTemplate(version, ['8.0', '10.0']), - ) -} - -main() diff --git a/src/postgenerate.ts b/src/postgenerate.ts deleted file mode 100644 index f35da16c..00000000 --- a/src/postgenerate.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { $ } from 'execa' - -const run = $({ stdio: 'inherit' }) - -await run`tsx src/generate-csproj.ts` -await run`dotnet tool restore` -await run`dotnet csharpier ./output/csharp` diff --git a/src/version.ts b/src/version.ts deleted file mode 100644 index 714eba75..00000000 --- a/src/version.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { readFile } from 'node:fs/promises' -import { fileURLToPath } from 'node:url' - -import { $ } from 'execa' - -const csprojFile = './output/csharp/src/Seam/Seam.csproj' - -const main = async (): Promise => { - const { version } = await readPackageJson() - - if (version == null) { - throw new Error('Missing version in package.json') - } - - await $({ stdio: 'inherit' })`tsx src/generate-csproj.ts` - - const data = await readFile( - fileURLToPath(new URL(`../${csprojFile}`, import.meta.url)), - ) - - if (!data.toString().includes(`${version}`)) { - throw new Error(`Could not find version ${version} in ${csprojFile}`) - } - - // eslint-disable-next-line no-console - console.log(`✓ Version ${version} injected into ${csprojFile}`) - - const { command } = await $`git add ${csprojFile}` - // eslint-disable-next-line no-console - console.log(`✓ Staged with '${command}'`) -} - -const readPackageJson = async (): Promise<{ version?: string }> => { - const pkgBuff = await readFile( - fileURLToPath(new URL('../package.json', import.meta.url)), - ) - return JSON.parse(pkgBuff.toString()) -} - -await main() diff --git a/output/csharp/src/Seam.Test/Client/ApiResponseTests.cs b/test/Seam.Test/Client/ApiResponseTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/ApiResponseTests.cs rename to test/Seam.Test/Client/ApiResponseTests.cs diff --git a/output/csharp/src/Seam.Test/Client/NullTests.cs b/test/Seam.Test/Client/NullTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/NullTests.cs rename to test/Seam.Test/Client/NullTests.cs diff --git a/output/csharp/src/Seam.Test/Client/RequestTransportTests.cs b/test/Seam.Test/Client/RequestTransportTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/RequestTransportTests.cs rename to test/Seam.Test/Client/RequestTransportTests.cs diff --git a/output/csharp/src/Seam.Test/Client/SeamTests.cs b/test/Seam.Test/Client/SeamTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/SeamTests.cs rename to test/Seam.Test/Client/SeamTests.cs diff --git a/output/csharp/src/Seam.Test/Client/StrictUrlSearchParamsSerializerTests.cs b/test/Seam.Test/Client/StrictUrlSearchParamsSerializerTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/StrictUrlSearchParamsSerializerTests.cs rename to test/Seam.Test/Client/StrictUrlSearchParamsSerializerTests.cs diff --git a/output/csharp/src/Seam.Test/Client/TimeoutTests.cs b/test/Seam.Test/Client/TimeoutTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/TimeoutTests.cs rename to test/Seam.Test/Client/TimeoutTests.cs diff --git a/output/csharp/src/Seam.Test/Client/UrlSearchParamsSerializerTests.cs b/test/Seam.Test/Client/UrlSearchParamsSerializerTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/UrlSearchParamsSerializerTests.cs rename to test/Seam.Test/Client/UrlSearchParamsSerializerTests.cs diff --git a/output/csharp/src/Seam.Test/Client/UrlSearchParamsTests.cs b/test/Seam.Test/Client/UrlSearchParamsTests.cs similarity index 100% rename from output/csharp/src/Seam.Test/Client/UrlSearchParamsTests.cs rename to test/Seam.Test/Client/UrlSearchParamsTests.cs diff --git a/output/csharp/src/Seam.Test/GlobalUsings.cs b/test/Seam.Test/GlobalUsings.cs similarity index 100% rename from output/csharp/src/Seam.Test/GlobalUsings.cs rename to test/Seam.Test/GlobalUsings.cs diff --git a/output/csharp/src/Seam.Test/Seam.Test.csproj b/test/Seam.Test/Seam.Test.csproj similarity index 93% rename from output/csharp/src/Seam.Test/Seam.Test.csproj rename to test/Seam.Test/Seam.Test.csproj index 6f275428..05858056 100644 --- a/output/csharp/src/Seam.Test/Seam.Test.csproj +++ b/test/Seam.Test/Seam.Test.csproj @@ -23,7 +23,7 @@ - + diff --git a/tsconfig.json b/tsconfig.json index 6190bfbf..c3d380f1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,5 +2,5 @@ "$schema": "https://json.schemastore.org/tsconfig.json", "extends": "./node_modules/@seamapi/smith/tsconfig.base.json", "files": ["codegen/index.ts"], - "include": ["codegen/**/*", "eslint.config.ts"] + "include": ["codegen/**/*", "eslint.config.ts", "version.ts"] } diff --git a/version.ts b/version.ts new file mode 100644 index 00000000..b63abae2 --- /dev/null +++ b/version.ts @@ -0,0 +1,50 @@ +import { readFile, writeFile } from 'node:fs/promises' +import { fileURLToPath } from 'node:url' + +import { $ } from 'execa' + +const versionFile = './src/Seam/Seam.csproj' + +const versionPattern = /[^<]*<\/Version>/ + +const main = async (): Promise => { + const version = await injectVersion( + fileURLToPath(new URL(versionFile, import.meta.url)), + ) + // eslint-disable-next-line no-console + console.log(`✓ Version ${version} injected into ${versionFile}`) + + const { command } = await $`git add ${versionFile}` + // eslint-disable-next-line no-console + console.log(`✓ Staged with '${command}'`) +} + +const injectVersion = async (path: string): Promise => { + const { version } = await readPackageJson() + + if (version == null) { + throw new Error('Missing version in package.json') + } + + const data = (await readFile(path)).toString() + + if (!versionPattern.test(data)) { + throw new Error(`Could not find the version element in ${versionFile}`) + } + + await writeFile( + path, + data.replace(versionPattern, `${version}`), + ) + + return version +} + +const readPackageJson = async (): Promise<{ version?: string }> => { + const pkgBuff = await readFile( + fileURLToPath(new URL('package.json', import.meta.url)), + ) + return JSON.parse(pkgBuff.toString()) +} + +await main()