Skip to content

Commit 5aee3ec

Browse files
committed
Initial commit showing package structure.
0 parents  commit 5aee3ec

File tree

13 files changed

+295
-0
lines changed

13 files changed

+295
-0
lines changed

.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Build directories
2+
bin/
3+
obj/
4+
5+
# User-specific files
6+
*.user
7+
*.userosscache
8+
*.suo
9+
*.sln.docstates
10+
*.userprefs
11+
*.rsuser
12+
13+
# Logs and debug output
14+
*.log
15+
*.tlog
16+
*.dmp
17+
18+
# Visual Studio specific
19+
.vscode/
20+
.vs/
21+
22+
# Rider specific
23+
.idea/
24+
*.sln.iml
25+
26+
# Build results
27+
*.dll
28+
*.exe
29+
*.pdb
30+
*.cache
31+
*.ilk
32+
*.lib
33+
*.obj
34+
*.sbr
35+
*.swp
36+
*.sln.ide
37+
*.tlog
38+
*.lastbuildstate
39+
*.idb
40+
41+
# NuGet packages
42+
*.nupkg
43+
*.snupkg
44+
packages/
45+
.nuget/
46+
47+
# Others
48+
TestResults/
49+
*.VSIXProjectLaunch
50+
.project
51+
.vsconfig

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p align="center">
2+
<a href="https://www.powersync.com" target="_blank"><img src="https://github.com/powersync-ja/.github/assets/7372448/d2538c43-c1a0-4c47-9a76-41462dba484f"/></a>
3+
</p>
4+
5+
_[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB or MySQL on the server-side._
6+
7+
# PowerSync .NET SDKs
8+
9+
`powersync-dot` is the monorepo for PowerSync .NET SDKs.

commands

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
dotnet new sln -n root
2+
dotnet new classlib -n Common
3+
dotnet sln root.sln add src/Common/Common.csproj
4+
dotnet add reference ../../packages/CommonUtilities/CommonUtilities.csproj
5+
6+
dotnet pack packages/CommonUtilities -o ../local-nuget
7+
dotnet add package CommonUtilities --version "*"
8+
9+
dotnet new xunit -n Common.Tests
10+
dotnet sln ../../root.sln add Common.Tests/Common.Tests.csproj
11+
12+
dotnet test src/Common/Common.Tests
13+
dotnet test --logger "console;verbosity=detailed" src/Common/Common.Tests
14+
dotnet test --logger "console;verbosity=detailed"

root.sln

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B1D87BA9-8812-4EFA-BBBE-1FF1EEEB5433}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "src\Common\Common.csproj", "{EA0A66FF-9E8A-4465-84EC-B2CFFC7E4393}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Tests", "src\Common.Tests\Common.Tests.csproj", "{B4FD0CE4-4265-4906-A203-3B15300FF44C}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{EA0A66FF-9E8A-4465-84EC-B2CFFC7E4393}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{EA0A66FF-9E8A-4465-84EC-B2CFFC7E4393}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{EA0A66FF-9E8A-4465-84EC-B2CFFC7E4393}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{EA0A66FF-9E8A-4465-84EC-B2CFFC7E4393}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{B4FD0CE4-4265-4906-A203-3B15300FF44C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{B4FD0CE4-4265-4906-A203-3B15300FF44C}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{B4FD0CE4-4265-4906-A203-3B15300FF44C}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{B4FD0CE4-4265-4906-A203-3B15300FF44C}.Release|Any CPU.Build.0 = Release|Any CPU
29+
EndGlobalSection
30+
GlobalSection(NestedProjects) = preSolution
31+
{EA0A66FF-9E8A-4465-84EC-B2CFFC7E4393} = {B1D87BA9-8812-4EFA-BBBE-1FF1EEEB5433}
32+
{B4FD0CE4-4265-4906-A203-3B15300FF44C} = {B1D87BA9-8812-4EFA-BBBE-1FF1EEEB5433}
33+
EndGlobalSection
34+
EndGlobal
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="coverlet.collector" Version="6.0.0" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
15+
<PackageReference Include="xunit" Version="2.5.3" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Using Include="Xunit" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<ProjectReference Include="..\Common\Common.csproj" />
25+
</ItemGroup>
26+
27+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Common.Tests;
2+
using Common.Client.Connection;
3+
public class PowerSyncCredentialsTests
4+
{
5+
[Fact]
6+
public void SimpleTest()
7+
{
8+
var endpoint = "http://localhost";
9+
var token = "token";
10+
var expiresAt = new DateTime();
11+
PowerSyncCredentials credentials = new PowerSyncCredentials(endpoint, token, expiresAt);
12+
Assert.Equal(endpoint, credentials.Endpoint);
13+
Assert.Equal(token, credentials.Token);
14+
Assert.Equal(expiresAt, credentials.ExpiresAt);
15+
}
16+
}

src/Common/Class1.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Common;
2+
3+
public class Class1
4+
{
5+
public void Write()
6+
{
7+
Console.WriteLine("Hello from Common!");
8+
}
9+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Common.DB.Crud;
2+
3+
namespace Common.Client;
4+
public abstract class AbstractPowerSyncDatabase {
5+
6+
// Returns true if the connection is closed.
7+
bool closed;
8+
bool ready;
9+
10+
string sdkVersion;
11+
SyncStatus syncStatus;
12+
13+
public AbstractPowerSyncDatabase() {
14+
this.syncStatus = new SyncStatus(new SyncStatusOptions());
15+
this.closed = false;
16+
this.ready = false;
17+
18+
this.sdkVersion = "";
19+
}
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Common.Client.Connection;
2+
3+
public interface IPowerSyncBackendConnector
4+
{
5+
// Allows the PowerSync client to retrieve an authentication token from your backend
6+
// which is used to authenticate against the PowerSync service.
7+
//
8+
// This should always fetch a fresh set of credentials - don't use cached
9+
// values.
10+
//
11+
// Return null if the user is not signed in. Throw an error if credentials
12+
// cannot be fetched due to a network error or other temporary error.
13+
//
14+
// This token is kept for the duration of a sync connection.
15+
Task<PowerSyncCredentials?> FetchCredentials();
16+
17+
// Upload local changes to the app backend.
18+
//
19+
// Use {@link AbstractPowerSyncDatabase.getCrudBatch} to get a batch of changes to upload.
20+
//
21+
// Any thrown errors will result in a retry after the configured wait period (default: 5 seconds).
22+
Task UploadData(AbstractPowerSyncDatabase database);
23+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Common.Client.Connection;
2+
public class PowerSyncCredentials(string endpoint, string token, DateTime? expiresAt = null)
3+
{
4+
public string Endpoint { get; set; } = endpoint;
5+
public string Token { get; set; } = token;
6+
public DateTime? ExpiresAt { get; set; } = expiresAt;
7+
}

0 commit comments

Comments
 (0)