Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
378 changes: 378 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion IsExternalInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace System.Runtime.CompilerServices
{
[EditorBrowsable(EditorBrowsableState.Never)]
internal class IsExternalInit { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ public class PowerSyncCredentials(string endpoint, string token, DateTime? expir
public string Endpoint { get; set; } = endpoint;
public string Token { get; set; } = token;
public DateTime? ExpiresAt { get; set; } = expiresAt;
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/Client/PowerSyncDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,4 @@ public class WatchOnChangeHandler
{
public Func<WatchOnChangeEvent, Task> OnChange { get; set; } = null!;
public Action<Exception>? OnError { get; set; }
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/Client/SQLOpenFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SQLOpenOptions : IDatabaseSource
public string? DbLocation { get; set; }
}

public interface ISQLOpenFactory: IDatabaseSource
public interface ISQLOpenFactory : IDatabaseSource
{
/// <summary>
/// Opens a connection adapter to a SQLite Database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ namespace PowerSync.Common.Client.Sync.Bucket;
using System;
using System.Threading.Tasks;

using Newtonsoft.Json;

using PowerSync.Common.DB.Crud;
using PowerSync.Common.Utils;
using Newtonsoft.Json;

public static class PowerSyncControlCommand
{
Expand Down Expand Up @@ -114,4 +115,4 @@ public interface IBucketStorageAdapter : IEventStream<BucketStorageEvent>
/// Invokes the `powersync_control` function for the sync client.
/// </summary>
Task<string> Control(string op, object? payload);
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/Client/Sync/Bucket/OpType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ public string ToJSON()
{
return JsonConvert.SerializeObject(Value).Trim('"'); // Ensures it's a string without extra quotes
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ public string ToJSON()

return JsonConvert.SerializeObject(jsonObject, Formatting.None);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public class SqliteBucketStorage : EventStream<BucketStorageEvent>, IBucketStora

private readonly IDBAdapter db;
private bool hasCompletedSync;
private bool pendingBucketDeletes;
private readonly bool pendingBucketDeletes;
private readonly HashSet<string> tableNames;
private string? clientId;

private ILogger logger;
private readonly ILogger logger;

private CancellationTokenSource updateCts;
private readonly CancellationTokenSource updateCts;

private record ExistingTableRowsResult(string name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ namespace PowerSync.Common.Client.Sync.Bucket;
public class SyncDataBatch(SyncDataBucket[] buckets)
{
public SyncDataBucket[] Buckets { get; private set; } = buckets;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace PowerSync.Common.Client.Sync.Bucket;

using System.Collections.Generic;
using System.Linq;

using Newtonsoft.Json;

public class SyncDataBucketJSON
Expand Down Expand Up @@ -71,4 +72,4 @@ public string ToJSON()

return JsonConvert.SerializeObject(jsonObject);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

using PowerSync.Common.DB.Crud;

namespace PowerSync.Common.Client.Sync.Stream;
Expand Down Expand Up @@ -169,4 +170,4 @@ public static DB.Crud.SyncStatusOptions CoreStatusToSyncStatusOptions(CoreSyncSt
PriorityStatusEntries = status.PriorityStatus.Select(PriorityToStatus).ToArray()
};
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/Client/Sync/Stream/Remote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace PowerSync.Common.Client.Sync.Stream;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace PowerSync.Common.Client.Sync.Stream;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

Expand Down Expand Up @@ -821,4 +822,4 @@ public async Task<T> ObtainLock<T>(LockOptions<T> lockOptions)
return await lockOptions.Callback();
});
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace PowerSync.Common.Client.Sync.Stream;

using Newtonsoft.Json;

using PowerSync.Common.Client.Sync.Bucket;
using PowerSync.Common.DB.Crud;
using Newtonsoft.Json;

public class ContinueCheckpointRequest
{
Expand Down
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/DB/Crud/CrudBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public async Task Complete(string? checkpoint = null)
{
await CompleteCallback(checkpoint);
}
}
}
3 changes: 2 additions & 1 deletion PowerSync/PowerSync.Common/DB/Crud/CrudEntry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace PowerSync.Common.DB.Crud;

using System.Collections.Generic;

using Newtonsoft.Json;

public enum UpdateType
Expand Down Expand Up @@ -107,4 +108,4 @@ public override int GetHashCode()
{
return JsonConvert.SerializeObject(this).GetHashCode();
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/DB/Crud/CrudTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ namespace PowerSync.Common.DB.Crud;
public class CrudTransaction(CrudEntry[] crud, Func<string?, Task> complete, long? transactionId = null) : CrudBatch(crud, false, complete)
{
public long? TransactionId { get; private set; } = transactionId;
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/DB/Crud/SyncProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ public class ProgressWithOperations
/// When this number reaches 1.0, all changes have been received from the sync service.
/// </summary>
public double DownloadedFraction { get; set; }
}
}
8 changes: 5 additions & 3 deletions PowerSync/PowerSync.Common/DB/Crud/SyncStatus.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace PowerSync.Common.DB.Crud;

using PowerSync.Common.Client.Sync.Stream;
using Newtonsoft.Json;
using Microsoft.Extensions.Options;

using Newtonsoft.Json;

using PowerSync.Common.Client.Sync.Stream;

public class SyncDataFlowStatus
{
[JsonProperty("downloading")] public bool Downloading { get; set; } = false;
Expand Down Expand Up @@ -199,4 +201,4 @@ private static int ComparePriorities(SyncPriorityStatus a, SyncPriorityStatus b)
{
return b.Priority - a.Priority; // Reverse because higher priorities have lower numbers
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/DB/Crud/UploadQueueStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public override string ToString()
return $"UploadQueueStats<count: {Count} size: {Size / 1024.0}kB>";
}
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/DB/Schema/Index.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ public string ToJSON(Table table)
columns = Columns.Select(column => column.ToJSON(table)).ToList()
});
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/DB/Schema/IndexedColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public object ToJSON(Table table)
}
);
}
}
}
3 changes: 2 additions & 1 deletion PowerSync/PowerSync.Common/DB/Schema/Table.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace PowerSync.Common.DB.Schema;

using System.Text.RegularExpressions;

using Newtonsoft.Json;

public class TableOptions(
Expand Down Expand Up @@ -183,4 +184,4 @@ public string ToJSON(string Name = "")

return JsonConvert.SerializeObject(jsonObject);
}
}
}
4 changes: 2 additions & 2 deletions PowerSync/PowerSync.Common/MDSQLite/MDSQLiteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MDSQLiteConnection : EventStream<DBAdapterEvent>, ILockContext
{

public SqliteConnection Db;
private List<UpdateNotification> updateBuffer;
private readonly List<UpdateNotification> updateBuffer;
public MDSQLiteConnection(MDSQLiteConnectionOptions options)
{
Db = options.Database;
Expand Down Expand Up @@ -215,4 +215,4 @@ public async Task RefreshSchema()
{
await Get<object>("PRAGMA table_info('sqlite_master')");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public IDBAdapter OpenDatabase()
SqliteOptions = options.SqliteOptions
});
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/MDSQLite/MDSQLiteOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ public class RequiredMDSQLiteOptions : MDSQLiteOptions

public new int CacheSizeKb { get; set; }
public new SqliteExtension[] Extensions { get; set; } = null!;
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/Utils/EventStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ private void RemoveSubscriber(Channel<T> channel)
{
subscribers.TryRemove(channel, out _);
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Common/Utils/PowerSyncPathResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ private static string GetFileNameForPlatform()
throw new PlatformNotSupportedException("Unsupported platform.");
}
}
}
}
3 changes: 2 additions & 1 deletion PowerSync/PowerSync.Maui/SQLite/MAUISQLiteAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace PowerSync.Maui.SQLite;

using Microsoft.Data.Sqlite;

using PowerSync.Common.MDSQLite;

// iOS specific imports
Expand Down Expand Up @@ -46,4 +47,4 @@ private void LoadExtensionIOS(SqliteConnection db)
loadExtension.ExecuteNonQuery();
#endif
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Maui/SQLite/MAUISQLiteDBOpenFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public IDBAdapter OpenDatabase()
SqliteOptions = options.SqliteOptions
});
}
}
}
2 changes: 1 addition & 1 deletion PowerSync/PowerSync.Maui/build/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace PowerSync.Maui.build
{
// Empty API definition - allows xcframework to be included without managed bindings
}
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ When running commands such as `dotnet run` or `dotnet test`, you may need to spe

# Development

## Setup Development Environment

### Formatting

This project uses [EditorConfig](https://editorconfig.org/) for formatting, which may require certain extensions/plugins to function properly in your IDE.

- **VSCode**: Available via [this extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig).
- **JetBrains Rider**: Supported by default.
- **Neovim**: Supported by default, or via the `gpanders/editorconfig.nvim` plugin for versions prior to `v0.9`.
- **Emacs**: Available via `editorconfig-mode`, or the `editorconfig` package for versions prior to `v30.1`.

### Project Setup

Download PowerSync extension

```bash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace PowerSync.Common.IntegrationTests;

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Collections.Generic;

using PowerSync.Common.DB.Crud;

public class NodeClient
Expand Down Expand Up @@ -157,4 +158,4 @@ public void Dispose()
{
_httpClient?.Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.IO;

using PowerSync.Common.Client;
using PowerSync.Common.Client.Connection;
using PowerSync.Common.DB.Crud;
Expand Down Expand Up @@ -110,4 +111,4 @@ public async Task UploadData(IPowerSyncDatabase database)
throw;
}
}
}
}
Loading