From 35b925ada410508aff819b7f6d30231cfd39a4e6 Mon Sep 17 00:00:00 2001 From: Janez Stupar Date: Fri, 27 Oct 2023 12:04:42 +0200 Subject: [PATCH] Fix licensing. --- NOTICE | 9 +++++++++ build.yaml | 18 ------------------ example/example.dart | 6 +++++- lib/src/crdt_util.dart | 6 ++++++ lib/src/is_web_io.dart | 4 ++++ lib/src/is_web_locator.dart | 4 ++++ lib/src/is_web_web.dart | 4 ++++ lib/src/sqflite_api.dart | 2 ++ lib/src/sqflite_crdt_impl.dart | 4 +++- lib/src/sqlite_api.dart | 4 ++++ lib/src/transaction.dart | 4 ++++ lib/synchroflite.dart | 16 ++++++++++------ ...e_crdt_test.dart => synchroflite_test.dart} | 9 +++++++-- 13 files changed, 62 insertions(+), 28 deletions(-) create mode 100644 NOTICE delete mode 100644 build.yaml rename test/{sqlite_crdt_test.dart => synchroflite_test.dart} (96%) diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..6f28787 --- /dev/null +++ b/NOTICE @@ -0,0 +1,9 @@ +Synchroflite +Copyright 2023 and onwards Janez Stupar + +This project is based on software developed by Daniel Cachapa and licensed under APACHE 2.0 license. + +You can find original work here: +https://github.com/cachapa/sql_crdt +https://github.com/cachapa/sqlite_crdt + diff --git a/build.yaml b/build.yaml deleted file mode 100644 index 497f226..0000000 --- a/build.yaml +++ /dev/null @@ -1,18 +0,0 @@ -targets: - $default: - builders: - json_serializable: - options: - any_map: false - checked: false - constructor: "" - create_factory: true - create_field_map: false - create_per_field_to_json: false - create_to_json: true - disallow_unrecognized_keys: false - explicit_to_json: false - field_rename: none - generic_argument_factories: false - ignore_unannotated: false - include_if_null: true diff --git a/example/example.dart b/example/example.dart index c06afb0..6142cd7 100644 --- a/example/example.dart +++ b/example/example.dart @@ -1,8 +1,12 @@ +// Copyright 2023 Janez Stupar +// This code is based on Daniel Cachapa's work in sqlite_crdt: +// https://github.com/cachapa/sqlite_crdt +// SPDX-License-Identifier: Apache-2.0 import 'package:synchroflite/synchroflite.dart'; Future main() async { // Create or load the database - final crdt = await SqfliteCrdt.openInMemory( + final crdt = await Synchroflite.openInMemory( version: 1, onCreate: (db, version) async { // Create a table diff --git a/lib/src/crdt_util.dart b/lib/src/crdt_util.dart index 242f056..2061e33 100644 --- a/lib/src/crdt_util.dart +++ b/lib/src/crdt_util.dart @@ -1,7 +1,13 @@ +// Copyright 2023 Janez Stupar +// This code is based on Daniel Cachapa's work in sql_crdt: +// https://github.com/cachapa/sql_crdt +// SPDX-License-Identifier: Apache-2.0 + import 'package:source_span/source_span.dart'; import 'package:collection/collection.dart'; import 'package:sqlparser/sqlparser.dart'; +// This class contains utility functions for transforming SQL statements that has been extracted from `sql_crdt` package. class CrdtUtil { static final _sqlEngine = SqlEngine(); diff --git a/lib/src/is_web_io.dart b/lib/src/is_web_io.dart index 9e903a1..f382ac6 100644 --- a/lib/src/is_web_io.dart +++ b/lib/src/is_web_io.dart @@ -1,3 +1,7 @@ +// Copyright 2023 Daniel Cachapa +// This file is copied from sqlite_crdt package: +// https://github.com/cachapa/sqlite_crdt +// SPDX-License-Identifier: Apache-2.0 import 'dart:io'; const sqliteCrdtIsWeb = false; diff --git a/lib/src/is_web_locator.dart b/lib/src/is_web_locator.dart index ced757f..b7f2950 100644 --- a/lib/src/is_web_locator.dart +++ b/lib/src/is_web_locator.dart @@ -1,3 +1,7 @@ +// Copyright 2023 Daniel Cachapa +// This file is copied from sqlite_crdt package: +// https://github.com/cachapa/sqlite_crdt +// SPDX-License-Identifier: Apache-2.0 import 'is_web_io.dart' if (dart.library.html) 'is_web_web.dart' as test; bool get sqliteCrdtIsWeb => test.sqliteCrdtIsWeb; diff --git a/lib/src/is_web_web.dart b/lib/src/is_web_web.dart index 8651fc4..63fa34e 100644 --- a/lib/src/is_web_web.dart +++ b/lib/src/is_web_web.dart @@ -1,2 +1,6 @@ +// Copyright 2023 Daniel Cachapa +// This file is copied from sqlite_crdt package: +// https://github.com/cachapa/sqlite_crdt +// SPDX-License-Identifier: Apache-2.0 const sqliteCrdtIsWeb = true; final sqliteCrdtIsLinux = false; diff --git a/lib/src/sqflite_api.dart b/lib/src/sqflite_api.dart index bbb7a02..26caf08 100644 --- a/lib/src/sqflite_api.dart +++ b/lib/src/sqflite_api.dart @@ -1,3 +1,5 @@ +// Copyright 2023 Janez Stupar +// SPDX-License-Identifier: Apache-2.0 import 'package:sqflite_common/sqlite_api.dart'; import 'package:synchroflite/src/sqlite_api.dart'; diff --git a/lib/src/sqflite_crdt_impl.dart b/lib/src/sqflite_crdt_impl.dart index 3612b6f..937d94c 100644 --- a/lib/src/sqflite_crdt_impl.dart +++ b/lib/src/sqflite_crdt_impl.dart @@ -1,4 +1,5 @@ - +// Copyright 2023 Janez Stupar +// SPDX-License-Identifier: Apache-2.0 part of 'package:synchroflite/synchroflite.dart'; // Queries that don't need to be intercepted and transformed @@ -6,6 +7,7 @@ const specialQueries = { 'SELECT 1', }; +// This mixin is used to override the default implementation of rawQuery, rawUpdate, rawInsert, and rawDelete mixin class SqfliteCrdtImplMixin { Object? _convert(Object? value) => (value is Hlc) ? value.toString() : value; diff --git a/lib/src/sqlite_api.dart b/lib/src/sqlite_api.dart index cb58351..49eee1e 100644 --- a/lib/src/sqlite_api.dart +++ b/lib/src/sqlite_api.dart @@ -1,3 +1,7 @@ +// Copyright 2023 Daniel Cachapa +// This file is copied from sqlite_crdt package: +// https://github.com/cachapa/sqlite_crdt +// SPDX-License-Identifier: Apache-2.0 import 'package:sqflite_common/sqlite_api.dart'; import 'package:sql_crdt/sql_crdt.dart'; diff --git a/lib/src/transaction.dart b/lib/src/transaction.dart index 9dadcd4..d191b50 100644 --- a/lib/src/transaction.dart +++ b/lib/src/transaction.dart @@ -1,3 +1,7 @@ +// Copyright 2023 Janez Stupar +// This code is based on Daniel Cachapa's work in sql_crdt: +// https://github.com/cachapa/sql_crdt +// SPDX-License-Identifier: Apache-2.0 part of 'package:synchroflite/synchroflite.dart'; class TransactionSqfliteCrdt extends TransactionCrdt with SqfliteCrdtImplMixin { diff --git a/lib/synchroflite.dart b/lib/synchroflite.dart index b531469..d2ae197 100644 --- a/lib/synchroflite.dart +++ b/lib/synchroflite.dart @@ -1,3 +1,7 @@ +// Copyright 2023 Janez Stupar +// This code is based on Daniel Cachapa's work in sqlite_crdt: +// https://github.com/cachapa/sqlite_crdt +// SPDX-License-Identifier: Apache-2.0 library synchroflite; import 'dart:async'; @@ -24,16 +28,16 @@ export 'package:synchroflite/src/sqflite_api.dart'; part 'package:synchroflite/src/sqflite_crdt_impl.dart'; part 'package:synchroflite/src/transaction.dart'; -class SqfliteCrdt extends SqlCrdt with SqfliteCrdtImplMixin { +class Synchroflite extends SqlCrdt with SqfliteCrdtImplMixin { final SqfliteApi _db; - SqfliteCrdt(this._db): super(_db); + Synchroflite(this._db): super(_db); /// Open or create a SQLite container as a SqlCrdt instance. /// /// See the Sqflite documentation for more details on opening a database: /// https://github.com/tekartik/sqflite/blob/master/sqflite/doc/opening_db.md - static Future open( + static Future open( String path, { bool singleInstance = true, int? version, @@ -45,7 +49,7 @@ class SqfliteCrdt extends SqlCrdt with SqfliteCrdtImplMixin { /// Open a transient SQLite in memory. /// Useful for testing or temporary sessions. - static Future openInMemory({ + static Future openInMemory({ bool singleInstance = false, int? version, FutureOr Function(BaseCrdt crdt, int version)? onCreate, @@ -54,7 +58,7 @@ class SqfliteCrdt extends SqlCrdt with SqfliteCrdtImplMixin { }) => _open(null, true, singleInstance, version, onCreate, onUpgrade, migrate: migrate); - static Future _open( + static Future _open( String? path, bool inMemory, bool singleInstance, @@ -89,7 +93,7 @@ class SqfliteCrdt extends SqlCrdt with SqfliteCrdtImplMixin { ), ); - final crdt = SqfliteCrdt(SqfliteApi(db)); + final crdt = Synchroflite(SqfliteApi(db)); try { await crdt.init(); } on DatabaseException catch (e) { diff --git a/test/sqlite_crdt_test.dart b/test/synchroflite_test.dart similarity index 96% rename from test/sqlite_crdt_test.dart rename to test/synchroflite_test.dart index cfd8036..9bf8993 100644 --- a/test/sqlite_crdt_test.dart +++ b/test/synchroflite_test.dart @@ -1,3 +1,8 @@ +// Copyright 2023 Daniel Cachapa +// Copyright 2023 Janez Stupar +// This file is copied from sqlite_crdt package: +// https://github.com/cachapa/sqlite_crdt +// SPDX-License-Identifier: Apache-2.0 import 'package:synchroflite/synchroflite.dart'; import 'package:test/test.dart'; @@ -6,7 +11,7 @@ void main() { late SqlCrdt crdt; setUp(() async { - crdt = await SqfliteCrdt.openInMemory( + crdt = await Synchroflite.openInMemory( version: 1, onCreate: (db, version) async { await db.execute(''' @@ -140,7 +145,7 @@ void main() { late SqlCrdt crdt; setUp(() async { - crdt = await SqfliteCrdt.openInMemory( + crdt = await Synchroflite.openInMemory( version: 1, onCreate: (db, version) async { await db.execute('''