Skip to content

Commit

Permalink
Fix licensing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Janez Stupar committed Oct 27, 2023
1 parent a03c2c9 commit 35b925a
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 28 deletions.
9 changes: 9 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -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

18 changes: 0 additions & 18 deletions build.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion example/example.dart
Original file line number Diff line number Diff line change
@@ -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<void> 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
Expand Down
6 changes: 6 additions & 0 deletions lib/src/crdt_util.dart
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
4 changes: 4 additions & 0 deletions lib/src/is_web_io.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions lib/src/is_web_locator.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions lib/src/is_web_web.dart
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions lib/src/sqflite_api.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 3 additions & 1 deletion lib/src/sqflite_crdt_impl.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

// 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
const specialQueries = <String> {
'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;
Expand Down
4 changes: 4 additions & 0 deletions lib/src/sqlite_api.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 4 additions & 0 deletions lib/src/transaction.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
16 changes: 10 additions & 6 deletions lib/synchroflite.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<SqfliteCrdt> open(
static Future<Synchroflite> open(
String path, {
bool singleInstance = true,
int? version,
Expand All @@ -45,7 +49,7 @@ class SqfliteCrdt extends SqlCrdt with SqfliteCrdtImplMixin {

/// Open a transient SQLite in memory.
/// Useful for testing or temporary sessions.
static Future<SqfliteCrdt> openInMemory({
static Future<Synchroflite> openInMemory({
bool singleInstance = false,
int? version,
FutureOr<void> Function(BaseCrdt crdt, int version)? onCreate,
Expand All @@ -54,7 +58,7 @@ class SqfliteCrdt extends SqlCrdt with SqfliteCrdtImplMixin {
}) =>
_open(null, true, singleInstance, version, onCreate, onUpgrade, migrate: migrate);

static Future<SqfliteCrdt> _open(
static Future<Synchroflite> _open(
String? path,
bool inMemory,
bool singleInstance,
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions test/sqlite_crdt_test.dart → test/synchroflite_test.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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('''
Expand Down Expand Up @@ -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('''
Expand Down

0 comments on commit 35b925a

Please sign in to comment.