Skip to content

Commit dabda64

Browse files
committed
Merge branch 'main' into feat/api-catchup-effort-2
2 parents c159031 + fb7e312 commit dabda64

File tree

116 files changed

+4983
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+4983
-190
lines changed

.github/workflows/dev-packages.yml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,63 @@
11
# The version is pulled from the CHANGELOG.md file of the package.
2-
# Add a `-dev.xxx` suffix to the version.
2+
# Add a `-dev.xxx` suffix to the version. Example: `0.0.1-dev.1`
33
name: Create Dev Release
44

55
on: workflow_dispatch
66

77
jobs:
88
dev-release:
99
name: Publish Dev Packages
10-
runs-on: windows-latest
10+
runs-on: macos-latest
1111

1212
steps:
1313
- name: Checkout Repository
1414
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.ref }}
1517

1618
- name: Setup .NET SDK
1719
uses: actions/setup-dotnet@v4
1820
with:
19-
dotnet-version: '8.0'
21+
dotnet-version: '8.0'
22+
23+
- name: Install MAUI Workloads
24+
run: dotnet workload restore
2025

2126
- name: Download PowerSync extension
2227
run: dotnet run --project Tools/Setup
2328

2429
- name: Restore dependencies
2530
run: dotnet restore
2631

27-
- name: Extract Version from CHANGELOG.md
32+
- name: Extract Common Package Version from CHANGELOG.md
2833
id: extract_version
2934
shell: bash
3035
run: |
31-
VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
32-
echo "Detected Version: $VERSION"
33-
echo "VERSION=$VERSION" >> $GITHUB_ENV
36+
COMMON_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
37+
echo "Detected Version: $COMMON_VERSION"
38+
echo "VERSION=$COMMON_VERSION" >> $GITHUB_ENV
39+
40+
- name: Run Pack For Common
41+
run: dotnet pack PowerSync/PowerSync.Common -c Release -o ${{ github.workspace }}/output
42+
43+
- name: Run Push For Common
44+
continue-on-error: true
45+
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Common*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
46+
47+
- name: Extract MAUI Package Version from CHANGELOG.md
48+
id: extract_maui_version
49+
shell: bash
50+
run: |
51+
MAUI_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Maui/CHANGELOG.md)
52+
echo "Detected Version: $MAUI_VERSION"
53+
echo "VERSION=$MAUI_VERSION" >> $GITHUB_ENV
54+
55+
- name: Build MAUI Project
56+
run: dotnet build PowerSync/PowerSync.Maui -c Release
3457

35-
- name: Run Pack
36-
run: dotnet pack -c Release -o ${{ github.workspace }}/output
58+
- name: Run Pack For MAUI
59+
run: dotnet pack PowerSync/PowerSync.Maui -c Release -o ${{ github.workspace }}/output
3760

38-
- name: Run Push
39-
run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
40-
61+
- name: Run Push For MAUI
62+
continue-on-error: true
63+
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Maui*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}

.github/workflows/release.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,58 @@ on: workflow_dispatch
66
jobs:
77
release:
88
name: Release
9-
runs-on: windows-latest
9+
runs-on: macos-latest
1010
if: github.ref == 'refs/heads/main'
1111

1212
steps:
1313
- name: Checkout Repository
1414
uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.ref }}
1517

1618
- name: Setup .NET SDK
1719
uses: actions/setup-dotnet@v4
1820
with:
19-
dotnet-version: '8.0'
21+
dotnet-version: '8.0'
22+
23+
- name: Install MAUI Workloads
24+
run: dotnet workload restore
2025

2126
- name: Download PowerSync extension
2227
run: dotnet run --project Tools/Setup
2328

2429
- name: Restore dependencies
2530
run: dotnet restore
2631

27-
- name: Extract Version from CHANGELOG.md
32+
- name: Extract Common Package Version from CHANGELOG.md
2833
id: extract_version
2934
shell: bash
3035
run: |
3136
VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/ {print $2; exit}' PowerSync/PowerSync.Common/CHANGELOG.md)
3237
echo "Detected Version: $VERSION"
3338
echo "VERSION=$VERSION" >> $GITHUB_ENV
3439
35-
- name: Run Pack
36-
run: dotnet pack -c Release -o ${{ github.workspace }}/output
40+
- name: Run Pack for Common
41+
run: dotnet pack PowerSync/PowerSync.Common -c Release -o ${{ github.workspace }}/output
42+
43+
- name: Run Push for Common
44+
continue-on-error: true
45+
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Common*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
3746

38-
- name: Run Push
39-
run: dotnet nuget push ${{ github.workspace }}\output\*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
40-
47+
- name: Extract MAUI Package Version from CHANGELOG.md
48+
id: extract_maui_version
49+
shell: bash
50+
run: |
51+
MAUI_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/ {print $2; exit}' PowerSync/PowerSync.Maui/CHANGELOG.md)
52+
echo "Detected Version: $MAUI_VERSION"
53+
echo "VERSION=$MAUI_VERSION" >> $GITHUB_ENV
54+
55+
- name: Build MAUI Project
56+
run: dotnet build PowerSync/PowerSync.Maui -c Release
57+
58+
- name: Run Pack For MAUI
59+
run: dotnet pack PowerSync/PowerSync.Maui -c Release -o ${{ github.workspace }}/output
60+
61+
- name: Run Push For MAUI
62+
continue-on-error: true
63+
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Maui*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ obj/
1414
*.log
1515
*.tlog
1616
*.dmp
17+
*.tmp
1718

1819
# Visual Studio specific
1920
.vscode/
@@ -61,3 +62,9 @@ TestResults/
6162
*.dylib
6263
*.dll
6364
*.so
65+
*.xcframework
66+
.env
67+
*NativeLibs
68+
69+
# Ignore user id file
70+
user_id.txt

PowerSync/PowerSync.Common/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# PowerSync.Common Changelog
2+
3+
## 0.0.4-alpha.1
4+
- Fixed MAUI issues related to extension loading when installing package outside of the monorepo.
5+
6+
## 0.0.3-alpha.1
7+
- Minor changes to accommodate PowerSync.MAUI package extension.
8+
19
## 0.0.2-alpha.2
210

311
- Updated core extension to v0.3.14

PowerSync/PowerSync.Common/Client/PowerSyncDatabase.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ public class DBAdapterSource(IDBAdapter Adapter) : IDatabaseSource
3535
public IDBAdapter Adapter { get; init; } = Adapter;
3636
}
3737

38-
public class OpenFactorySource(ISQLOpenFactory Factory) : IDatabaseSource
39-
{
40-
public ISQLOpenFactory Factory { get; init; } = Factory;
41-
}
42-
4338
public class PowerSyncDatabaseOptions() : BasePowerSyncDatabaseOptions()
4439
{
4540
/// <summary>
@@ -113,9 +108,9 @@ public PowerSyncDatabase(PowerSyncDatabaseOptions options)
113108
{
114109
Database = adapterSource.Adapter;
115110
}
116-
else if (options.Database is OpenFactorySource factorySource)
111+
else if (options.Database is ISQLOpenFactory factorySource)
117112
{
118-
Database = factorySource.Factory.OpenDatabase();
113+
Database = factorySource.OpenDatabase();
119114
}
120115
else if (options.Database is SQLOpenOptions openOptions)
121116
{
@@ -158,7 +153,7 @@ public async Task WaitForReady()
158153

159154
await isReadyTask;
160155
}
161-
156+
162157
public class PrioritySyncRequest
163158
{
164159
public CancellationToken? Token { get; set; }
@@ -176,7 +171,7 @@ public class PrioritySyncRequest
176171
/// <returns>A task which will complete once the first full sync has completed.</returns>
177172
public async Task WaitForFirstSync(PrioritySyncRequest? request = null)
178173
{
179-
var priority = request?.Priority ?? null;
174+
var priority = request?.Priority ?? null;
180175
var cancellationToken = request?.Token ?? null;
181176

182177
bool StatusMatches(SyncStatus status)
@@ -200,7 +195,7 @@ bool StatusMatches(SyncStatus status)
200195
{
201196
foreach (var update in Listen(cts.Token))
202197
{
203-
if (update.StatusChanged != null && StatusMatches(update.StatusChanged!))
198+
if (update.StatusChanged != null && StatusMatches(update.StatusChanged!))
204199
{
205200
cts.Cancel();
206201
tcs.SetResult(true);
@@ -295,7 +290,7 @@ protected async Task UpdateHasSynced()
295290
PriorityStatusEntries = priorityStatuses.ToArray(),
296291
LastSyncedAt = lastCompleteSync,
297292
});
298-
293+
299294
if (!updatedStatus.IsEqual(CurrentStatus))
300295
{
301296
CurrentStatus = updatedStatus;

PowerSync/PowerSync.Common/Client/SQLOpenFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SQLOpenOptions : IDatabaseSource
1515
public string? DbLocation { get; set; }
1616
}
1717

18-
public interface ISQLOpenFactory
18+
public interface ISQLOpenFactory: IDatabaseSource
1919
{
2020
/// <summary>
2121
/// Opens a connection adapter to a SQLite Database.

PowerSync/PowerSync.Common/Client/Sync/Stream/Remote.cs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace PowerSync.Common.Client.Sync.Stream;
1414
public class SyncStreamOptions
1515
{
1616
public string Path { get; set; } = "";
17-
17+
1818
public StreamingSyncRequest Data { get; set; } = new();
1919
public Dictionary<string, string> Headers { get; set; } = new();
2020

@@ -23,6 +23,9 @@ public class SyncStreamOptions
2323

2424
public class Remote
2525
{
26+
27+
private const int STREAMING_POST_TIMEOUT_MS = 30_000;
28+
2629
private readonly HttpClient httpClient;
2730
protected IPowerSyncBackendConnector connector;
2831

@@ -113,34 +116,37 @@ public async Task<T> Get<T>(string path, Dictionary<string, string>? headers = n
113116
var responseData = await response.Content.ReadAsStringAsync();
114117
return JsonConvert.DeserializeObject<T>(responseData)!;
115118
}
116-
117-
/// <summary>
118-
/// Posts to the stream endpoint and returns a raw NDJSON stream that can be read line by line.
119-
/// </summary>
120-
public async Task<Stream> PostStreamRaw(SyncStreamOptions options)
121-
{
122-
var requestMessage = await BuildRequest(HttpMethod.Post, options.Path, options.Data, options.Headers);
123-
var response = await httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, options.CancellationToken);
124119

125-
if (response.Content == null)
120+
public static StreamingSyncLine? ParseStreamingSyncLine(JObject json)
121+
{
122+
// Determine the type based on available keys
123+
if (json.ContainsKey("checkpoint"))
126124
{
127-
throw new HttpRequestException($"HTTP {response.StatusCode}: No content");
125+
return json.ToObject<StreamingSyncCheckpoint>();
128126
}
129-
130-
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) {
131-
InvalidateCredentials();
127+
else if (json.ContainsKey("checkpoint_diff"))
128+
{
129+
return json.ToObject<StreamingSyncCheckpointDiff>();
132130
}
133-
134-
if (!response.IsSuccessStatusCode)
131+
else if (json.ContainsKey("checkpoint_complete"))
135132
{
136-
var errorText = await response.Content.ReadAsStringAsync();
137-
throw new HttpRequestException($"HTTP {response.StatusCode}: {errorText}");
133+
return json.ToObject<StreamingSyncCheckpointComplete>();
134+
}
135+
else if (json.ContainsKey("data"))
136+
{
137+
return json.ToObject<StreamingSyncDataJSON>();
138+
}
139+
else if (json.ContainsKey("token_expires_in"))
140+
{
141+
return json.ToObject<StreamingSyncKeepalive>();
142+
}
143+
else
144+
{
145+
return null;
138146
}
139-
140-
return await response.Content.ReadAsStreamAsync();
141147
}
142148

143-
149+
144150
private async Task<HttpRequestMessage> BuildRequest(HttpMethod method, string path, object? data = null, Dictionary<string, string>? additionalHeaders = null)
145151
{
146152
var credentials = await GetCredentials();

0 commit comments

Comments
 (0)