Skip to content

Commit 2a9d1a5

Browse files
committed
Initial commit
1 parent ca9bafe commit 2a9d1a5

16 files changed

Lines changed: 372 additions & 368 deletions

File tree

PowerSync/PowerSync.Common/PowerSync.Common.csproj

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net8.0-maccatalyst;net9.0-ios;net9.0-android;net9.0-maccatalyst</TargetFrameworks>
4+
<DefaultTargetFrameworks>net8.0;net9.0;net10.0;net9.0-android;net10.0-android</DefaultTargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(DefaultTargetFrameworks);net9.0-ios;net10.0-ios;net9.0-maccatalyst;net10.0-maccatalyst</TargetFrameworks>
6+
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('OSX'))">$(DefaultTargetFrameworks)</TargetFrameworks>
7+
58
<LangVersion>12</LangVersion>
69
<ImplicitUsings>enable</ImplicitUsings>
710
<Nullable>enable</Nullable>
@@ -27,22 +30,26 @@
2730
</ItemGroup>
2831

2932
<ItemGroup>
30-
<PackageReference Include="Dapper" Version="2.1.66" />
31-
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.1" />
32-
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.1" />
33-
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
34-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
35-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
33+
<PackageReference Include="Dapper" Version="2.1.79" />
34+
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.9" />
35+
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.9" />
36+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.9" />
37+
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
3638
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
37-
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
38-
<PackageReference Include="ThrottleDebounce" Version="2.0.1" />
39+
<PackageReference Include="System.Threading.Channels" Version="10.0.9" />
40+
<PackageReference Include="ThrottleDebounce" Version="2.0.2" />
3941
</ItemGroup>
4042

4143
<ItemGroup>
4244
<None Include="PowerSync.Common.targets" Pack="true" PackagePath="build\" />
4345
<None Include="PowerSync.Common.targets" Pack="true" PackagePath="buildTransitive\" />
4446
</ItemGroup>
45-
47+
48+
<ItemGroup>
49+
<!-- Temporary workaround until vulnerability fixed: https://github.com/dotnet/efcore/issues/38257 -->
50+
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" VersionOverride="3.0.3" />
51+
</ItemGroup>
52+
4653
<!-- Check allows us to skip for all MAUI targets-->
4754
<!-- For monorepo-->
4855
<ItemGroup Condition="!$(TargetFramework.EndsWith('-android')) AND !$(TargetFramework.EndsWith('-ios')) AND !$(TargetFramework.EndsWith('-maccatalyst'))">

PowerSync/PowerSync.Maui/PowerSync.Maui.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net8.0-maccatalyst;net9.0-ios;net9.0-android;net9.0-maccatalyst</TargetFrameworks>
4+
<DefaultTargetFrameworks>net9.0;net10.0;net9.0-android;net10.0-android</DefaultTargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(DefaultTargetFrameworks);net9.0-ios;net10.0-ios;net9.0-maccatalyst;net10.0-maccatalyst</TargetFrameworks>
6+
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('OSX'))">$(DefaultTargetFrameworks)</TargetFrameworks>
7+
58
<LangVersion>12</LangVersion>
69
<ImplicitUsings>enable</ImplicitUsings>
710
<Nullable>enable</Nullable>
Lines changed: 160 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,161 @@
1-
namespace PowerSync.Common.IntegrationTests;
2-
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Net.Http;
6-
using System.Text;
7-
using System.Text.Json;
8-
using System.Threading.Tasks;
9-
10-
using PowerSync.Common.DB.Crud;
11-
12-
public class NodeClient
13-
{
14-
private readonly HttpClient _httpClient;
15-
private readonly string _backendUrl;
16-
private readonly string _userId;
17-
18-
public NodeClient(string userId)
19-
{
20-
_httpClient = new HttpClient();
21-
_backendUrl = "http://localhost:6060";
22-
_userId = userId;
23-
}
24-
25-
public NodeClient(string backendUrl, string userId)
26-
{
27-
_httpClient = new HttpClient();
28-
_backendUrl = backendUrl;
29-
_userId = userId;
30-
}
31-
32-
public Task<string> CreateList(string id, string name)
33-
{
34-
return CreateItem("lists", id, name);
35-
}
36-
37-
async Task<string> CreateItem(string table, string id, string name)
38-
{
39-
var data = new Dictionary<string, object>
40-
{
41-
{ "created_at", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") },
42-
{ "name", name },
43-
{ "owner_id", _userId }
44-
};
45-
46-
var batch = new[]
47-
{
48-
new
49-
{
50-
op = UpdateType.PUT.ToString(),
51-
table = table,
52-
id = id,
53-
data = data
54-
}
55-
};
56-
57-
var payload = JsonSerializer.Serialize(new { batch });
58-
var content = new StringContent(payload, Encoding.UTF8, "application/json");
59-
60-
HttpResponseMessage response = await _httpClient.PostAsync($"{_backendUrl}/api/data", content);
61-
62-
if (!response.IsSuccessStatusCode)
63-
{
64-
Console.WriteLine(await response.Content.ReadAsStringAsync());
65-
throw new Exception(
66-
$"Failed to create item. Status: {response.StatusCode}, " +
67-
$"Response: {await response.Content.ReadAsStringAsync()}"
68-
);
69-
}
70-
71-
return await response.Content.ReadAsStringAsync();
72-
}
73-
74-
public Task<string> DeleteList(string id)
75-
{
76-
return DeleteItem("lists", id);
77-
}
78-
79-
public Task<string> CreateTodo(string id, string listId, string description)
80-
{
81-
return CreateTodoItem("todos", id, listId, description);
82-
}
83-
84-
async Task<string> CreateTodoItem(string table, string id, string listId, string description)
85-
{
86-
var data = new Dictionary<string, object>
87-
{
88-
{ "created_at", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") },
89-
{ "description", description },
90-
{ "list_id", listId },
91-
{ "created_by", _userId },
92-
{ "completed", 0 },
93-
};
94-
95-
var batch = new[]
96-
{
97-
new
98-
{
99-
op = UpdateType.PUT.ToString(),
100-
table = table,
101-
id = id,
102-
data = data
103-
}
104-
};
105-
106-
var payload = JsonSerializer.Serialize(new { batch });
107-
var content = new StringContent(payload, Encoding.UTF8, "application/json");
108-
109-
HttpResponseMessage response = await _httpClient.PostAsync($"{_backendUrl}/api/data", content);
110-
111-
if (!response.IsSuccessStatusCode)
112-
{
113-
Console.WriteLine(await response.Content.ReadAsStringAsync());
114-
throw new Exception(
115-
$"Failed to create todo. Status: {response.StatusCode}, " +
116-
$"Response: {await response.Content.ReadAsStringAsync()}"
117-
);
118-
}
119-
120-
return await response.Content.ReadAsStringAsync();
121-
}
122-
123-
public Task<string> DeleteTodo(string id)
124-
{
125-
return DeleteItem("todos", id);
126-
}
127-
128-
async Task<string> DeleteItem(string table, string id)
129-
{
130-
var batch = new[]
131-
{
132-
new
133-
{
134-
op = UpdateType.DELETE.ToString(),
135-
table = table,
136-
id = id
137-
}
138-
};
139-
140-
var payload = JsonSerializer.Serialize(new { batch });
141-
var content = new StringContent(payload, Encoding.UTF8, "application/json");
142-
143-
HttpResponseMessage response = await _httpClient.PostAsync($"{_backendUrl}/api/data", content);
144-
145-
if (!response.IsSuccessStatusCode)
146-
{
147-
Console.WriteLine(await response.Content.ReadAsStringAsync());
148-
throw new Exception(
149-
$"Failed to delete item. Status: {response.StatusCode}, " +
150-
$"Response: {await response.Content.ReadAsStringAsync()}"
151-
);
152-
}
153-
154-
return await response.Content.ReadAsStringAsync();
155-
}
156-
157-
public void Dispose()
158-
{
159-
_httpClient?.Dispose();
160-
}
1+
namespace PowerSync.Common.IntegrationTests;
2+
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Net.Http;
6+
using System.Text;
7+
using System.Text.Json;
8+
using System.Threading.Tasks;
9+
10+
using PowerSync.Common.DB.Crud;
11+
12+
public class NodeClient
13+
{
14+
private readonly HttpClient _httpClient;
15+
private readonly string _backendUrl;
16+
private readonly string _userId;
17+
18+
public NodeClient(string userId)
19+
{
20+
_httpClient = new HttpClient();
21+
_backendUrl = "http://localhost:6060";
22+
_userId = userId;
23+
}
24+
25+
public NodeClient(string backendUrl, string userId)
26+
{
27+
_httpClient = new HttpClient();
28+
_backendUrl = backendUrl;
29+
_userId = userId;
30+
}
31+
32+
public Task<string> CreateList(string id, string name)
33+
{
34+
return CreateItem("lists", id, name);
35+
}
36+
37+
async Task<string> CreateItem(string table, string id, string name)
38+
{
39+
var data = new Dictionary<string, object>
40+
{
41+
{ "created_at", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") },
42+
{ "name", name },
43+
{ "owner_id", _userId }
44+
};
45+
46+
var batch = new[]
47+
{
48+
new
49+
{
50+
op = UpdateType.PUT.ToString(),
51+
table = table,
52+
id = id,
53+
data = data
54+
}
55+
};
56+
57+
var payload = JsonSerializer.Serialize(new { batch });
58+
var content = new StringContent(payload, Encoding.UTF8, "application/json");
59+
60+
HttpResponseMessage response = await _httpClient.PostAsync($"{_backendUrl}/api/data", content);
61+
62+
if (!response.IsSuccessStatusCode)
63+
{
64+
Console.WriteLine(await response.Content.ReadAsStringAsync());
65+
throw new Exception(
66+
$"Failed to create item. Status: {response.StatusCode}, " +
67+
$"Response: {await response.Content.ReadAsStringAsync()}"
68+
);
69+
}
70+
71+
return await response.Content.ReadAsStringAsync();
72+
}
73+
74+
public Task<string> DeleteList(string id)
75+
{
76+
return DeleteItem("lists", id);
77+
}
78+
79+
public Task<string> CreateTodo(string id, string listId, string description)
80+
{
81+
return CreateTodoItem("todos", id, listId, description);
82+
}
83+
84+
async Task<string> CreateTodoItem(string table, string id, string listId, string description)
85+
{
86+
var data = new Dictionary<string, object>
87+
{
88+
{ "created_at", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") },
89+
{ "description", description },
90+
{ "list_id", listId },
91+
{ "created_by", _userId },
92+
{ "completed", 0 },
93+
};
94+
95+
var batch = new[]
96+
{
97+
new
98+
{
99+
op = UpdateType.PUT.ToString(),
100+
table = table,
101+
id = id,
102+
data = data
103+
}
104+
};
105+
106+
var payload = JsonSerializer.Serialize(new { batch });
107+
var content = new StringContent(payload, Encoding.UTF8, "application/json");
108+
109+
HttpResponseMessage response = await _httpClient.PostAsync($"{_backendUrl}/api/data", content);
110+
111+
if (!response.IsSuccessStatusCode)
112+
{
113+
Console.WriteLine(await response.Content.ReadAsStringAsync());
114+
throw new Exception(
115+
$"Failed to create todo. Status: {response.StatusCode}, " +
116+
$"Response: {await response.Content.ReadAsStringAsync()}"
117+
);
118+
}
119+
120+
return await response.Content.ReadAsStringAsync();
121+
}
122+
123+
public Task<string> DeleteTodo(string id)
124+
{
125+
return DeleteItem("todos", id);
126+
}
127+
128+
async Task<string> DeleteItem(string table, string id)
129+
{
130+
var batch = new[]
131+
{
132+
new
133+
{
134+
op = UpdateType.DELETE.ToString(),
135+
table = table,
136+
id = id
137+
}
138+
};
139+
140+
var payload = JsonSerializer.Serialize(new { batch });
141+
var content = new StringContent(payload, Encoding.UTF8, "application/json");
142+
143+
HttpResponseMessage response = await _httpClient.PostAsync($"{_backendUrl}/api/data", content);
144+
145+
if (!response.IsSuccessStatusCode)
146+
{
147+
Console.WriteLine(await response.Content.ReadAsStringAsync());
148+
throw new Exception(
149+
$"Failed to delete item. Status: {response.StatusCode}, " +
150+
$"Response: {await response.Content.ReadAsStringAsync()}"
151+
);
152+
}
153+
154+
return await response.Content.ReadAsStringAsync();
155+
}
156+
157+
public void Dispose()
158+
{
159+
_httpClient?.Dispose();
160+
}
161161
}

0 commit comments

Comments
 (0)