chore: Update to Serverpod 4.0.0-beta.4 (#112)

This commit is contained in:
Marcelo Mendonça Soares 2026-08-25 11:25:48 -03:00 • committed by GitHub
commit 852c81c64a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 29163 additions and 10676 deletions

32
.github/workflows/publish.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Publish to pub.dev
on:
workflow_dispatch:
push:
tags:
# Matches tags like `2.9.1` and `3.0.0-alpha.1` or `3.0.0-rc.1`
- '[0-9]+.[0-9]+.[0-9]+*'
jobs:
publish-serverpod_offline_sync:
permissions:
id-token: write
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
with:
working-directory: packages/serverpod_offline_sync
publish-serverpod_offline_sync_client:
needs: publish-serverpod_offline_sync
permissions:
id-token: write
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
with:
working-directory: packages/serverpod_offline_sync_client
publish-serverpod_offline_sync_server:
needs: publish-serverpod_offline_sync
permissions:
id-token: write
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
with:
working-directory: packages/serverpod_offline_sync_server

View file

@ -1,3 +1,10 @@
## 0.0.3
- fix: Requires non-nullable foreign keys to be `deferred`.
- fix: Rejects `onDelete=Restrict` on synced tables in favor of `onDelete=NoAction`.
- fix: Throws proper `DatabaseException` instead of bare `Exception` on the database.
- chore: Updated Serverpod to `4.0.0-beta.4`.
## 0.0.2
- fix: Skips tracking FKs for relations with non-sync tables.

View file

@ -101,17 +101,17 @@ Add the packages to the server and client `pubspec.yaml` files.
```yaml
# your_project_client/pubspec.yaml
dependencies:
serverpod_offline_sync_client: 0.0.2
serverpod_offline_sync_client: 0.0.3
```
```yaml
# your_project_server/pubspec.yaml
dependencies:
serverpod_offline_sync_server: 0.0.2
serverpod_offline_sync_server: 0.0.3
```
> [!NOTE]
> Version `0.0.2` requires Serverpod `4.0.0-beta.2`.
> Version `0.0.3` requires Serverpod `4.0.0-beta.4`.
After adding the dependencies, list the `serverpod_offline_sync` module on the
`generator.yaml` file:
@ -277,7 +277,8 @@ the design and can never be lifted.
- All 1:1 relations must have the foreign-key column nullable (`optional`
relation).
- The only allowed non-synced-to-synced relation is `scopeId -> crdt_scopes.id`.
- All foreign-key relations must be `deferrable` (pending [serverpod#5338](https://github.com/serverpod/serverpod/issues/5338)).
- Non-nullable foreign-key relations must be declared as `deferred`.
- Foreign-key action `onDelete=Restrict` must be replaced by `onDelete=NoAction`.
Respecting these limitations, all other database invariants — including
foreign-key actions — are preserved, with the exception of check constraints,
@ -293,12 +294,13 @@ which Serverpod does not support either.
Migrations are generated symmetrically for both ends. The engine respects the
three mathematical properties a CRDT must hold to be consistent: idempotence,
associativity, and commutativity.
- **Metadata model.** Three metadata tables track change history *without copying
row data*: `crdt_data_rows` (insert + visibility), `crdt_data_fields` (update),
and `crdt_data_tombstone` (delete/restore). Hybrid logical clocks order
field-level values and break ties. A monotone causal-length tombstone governs
row existence, so add/delete/restore advance generations forward and can never
oscillate.
- **Metadata model.** Four metadata tables track change history and relational
projection state: `crdt_data_rows` (insert + visibility), `crdt_data_fields`
(update), `crdt_data_foreign_key` (attempted and materialized foreign-key
values), and `crdt_data_tombstone` (delete/restore). Hybrid logical clocks
order field-level values and break ties. A monotone causal-length tombstone
governs row existence, so add/delete/restore advance generations forward and
can never oscillate.
- **Visibility as a pure function.** Replicas never coordinate. Each merge
applies remote facts monotonically, then derives the visible database —
tombstone state, unique-conflict winners, and foreign-key repair — as a

View file

@ -70,7 +70,6 @@ linter:
- prefer_final_in_for_each
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_is_empty
- prefer_is_not_empty
- prefer_iterable_whereType

View file

@ -11,7 +11,7 @@ dependencies:
benchmark_harness: ^2.4.0
intl: ^0.20.2
path: ^1.9.1
serverpod_database: 4.0.0-beta.2
serverpod_database: 4.0.0-beta.4
serverpod_offline_sync:
path: ../packages/serverpod_offline_sync
serverpod_offline_sync_server:

View file

@ -88,7 +88,8 @@ Due to the nature of merge conflicts, the package imposes some limitations on th
- Unique indexes are only supported with at least one `String`/`UuidValue`/nullable column.
- All 1:1 relations must have the foreign-key column nullable (`optional` relation).
- The only allowed non-synced-to-synced relation is `scopeId -> crdt_scopes.id`.
- All foreign-key relations must be `deferrable`* (see the technical debts section).
- Foreign-key relations that foreign-key projection cannot repair — non-nullable columns and composite relations — must be `deferred`.
- `onDelete=Restrict` is unsupported on synced tables; use `onDelete=NoAction`.
Respecting these limitations, all other database invariants, including foreign-key actions, are preserved - with the exception of check constraints, which are also not supported by Serverpod.
@ -176,7 +177,6 @@ The package is functionally in a production-ready state, but some APIs need to i
### Technical debts
- **Require that all foreign-key relations are declared deferrable**. Because the package does not store a copy of the data with the metadata, there are some scenarios in which the stored data might violate the causal order of the foreign-key constraints and a merge can fail irreversibly. To prevent this, all foreign-key constraints must be deferrable, which will be enabled by Serverpod's issue #5338.
- **Rename the `scope` name for data isolation to `space`**. This is a small refactor to avoid confusion with the `scope` keyword used in the Serverpod Auth modules. Using `space` is also clearer for usage on an application level.
### Post-integration UX improvements

View file

@ -16,7 +16,7 @@ dependencies:
http: ^1.5.0
path: ^1.9.1
path_provider: ^2.1.5
serverpod_database: 4.0.0-beta.2
serverpod_database: 4.0.0-beta.4
serverpod_offline_sync_client:
path: ../../packages/serverpod_offline_sync_client
serverpod_offline_sync_test_client:

View file

@ -69,7 +69,6 @@ linter:
- prefer_final_in_for_each
- prefer_final_locals
- prefer_foreach
- prefer_if_elements_to_conditional_expressions
- prefer_is_empty
- prefer_is_not_empty
- prefer_iterable_whereType

View file

@ -1,8 +1,8 @@
include: ../../analysis_options.yaml
analyzer:
exclude:
# - lib/src/generated/**
# analyzer:
# exclude:
# - lib/src/generated/**
formatter:
trailing_commas: preserve

View file

@ -560,9 +560,7 @@ class CrdtDatabase implements Database {
transaction: transaction,
);
if (result.length > 1) {
// FIXME: We can't use the proper `DatabaseUpsertRowException` because
// it is declared as a base type on the `serverpod_database` package.
throw Exception(
throw DatabaseUnexpectedResultException(
'Failed to upsert row, affected number of rows is ${result.length} != 1',
);
}
@ -655,9 +653,9 @@ class CrdtDatabase implements Database {
);
if (updatedRows.isEmpty) {
// FIXME: We can't use the proper `DatabaseUpdateRowException` because
// it is declared as a base type on the `serverpod_database` package.
throw Exception('Failed to update row, no rows updated.');
throw DatabaseUnexpectedResultException(
'Failed to update row, no rows updated',
);
}
final updatedRow = updatedRows.single;
@ -774,9 +772,9 @@ class CrdtDatabase implements Database {
);
if (deletedRows.isEmpty) {
// FIXME: We can't use the proper `DatabaseDeleteRowException` because
// it is declared as a base type on the `serverpod_database` package.
throw Exception('Failed to delete row, no rows deleted.');
throw DatabaseUnexpectedResultException(
'Failed to delete row, no rows deleted.',
);
}
return deletedRows.single;

View file

@ -97,6 +97,32 @@ class CrdtSchemaRegistry {
'$_scopeIdFieldHelp',
);
}
final nonDeferredForeignKeys = _nonDeferredForeignKeyViolations(
syncTables,
tableDefinitionsByName,
);
if (nonDeferredForeignKeys.isNotEmpty) {
throw StateError(
'CRDT requires deferred foreign keys for non-optional relations, but '
'${nonDeferredForeignKeys.length} foreign key(s) are not deferred: '
'${nonDeferredForeignKeys.map((fk) => '"$fk"').join(', ')}. Mark these '
'as "deferred" or make the relation optional.',
);
}
final restrictForeignKeys = _restrictForeignKeyViolations(
syncTables,
tableDefinitionsByName,
);
if (restrictForeignKeys.isNotEmpty) {
throw StateError(
'CRDT cannot synchronize tables with "onDelete=Restrict" foreign keys, '
'but ${restrictForeignKeys.length} foreign key(s) use it: '
'${restrictForeignKeys.map((fk) => '"$fk"').join(', ')}. Replace by '
'"onDelete=NoAction" instead, which produces the same effect.',
);
}
}
/// Help text appended to schema validation errors that describes the required
@ -259,12 +285,53 @@ List<String> _missingCrdtScopeRelations(
bool _hasCrdtScopeRelation(TableDefinition tableDefinition) {
return tableDefinition.foreignKeys.any(
(fk) =>
fk.columns.length == 1 &&
fk.columns.single == 'scopeId' &&
fk.referenceTable == 'crdt_scopes' &&
fk.referenceColumns.length == 1 &&
fk.referenceColumns.single == 'id' &&
fk.onDelete == ForeignKeyAction.cascade,
(fk) => _isCrdtScopeForeignKey(fk) && fk.onDelete == ForeignKeyAction.cascade,
);
}
bool _isCrdtScopeForeignKey(ForeignKeyDefinition fk) {
return fk.columns.length == 1 &&
fk.columns.single == 'scopeId' &&
fk.referenceTable == 'crdt_scopes' &&
fk.referenceColumns.length == 1 &&
fk.referenceColumns.single == 'id';
}
List<String> _nonDeferredForeignKeyViolations(
List<Table> syncTables,
Map<String, TableDefinition> tableDefinitionsByName,
) {
return [
for (final table in syncTables)
if (tableDefinitionsByName[table.tableName] case final tableDefinition?)
for (final fk in tableDefinition.foreignKeys)
if (!_isCrdtScopeForeignKey(fk) &&
!_isRepairableByProjection(fk, tableDefinition) &&
fk.deferrable != DeferrableConstraint.initiallyDeferred)
'${table.tableName}.${fk.columns.join(',')}',
];
}
bool _isRepairableByProjection(
ForeignKeyDefinition fk,
TableDefinition tableDefinition,
) {
if (fk.columns.length != 1) return false;
for (final column in tableDefinition.columns) {
if (column.name == fk.columns.single) return column.isNullable;
}
return false;
}
List<String> _restrictForeignKeyViolations(
List<Table> syncTables,
Map<String, TableDefinition> tableDefinitionsByName,
) {
return [
for (final table in syncTables)
if (tableDefinitionsByName.containsKey(table.tableName))
for (final fk in tableDefinitionsByName[table.tableName]!.foreignKeys)
if (!_isCrdtScopeForeignKey(fk) && fk.onDelete == ForeignKeyAction.restrict)
'${table.tableName}.${fk.columns.join(',')}',
];
}

View file

@ -11,16 +11,17 @@
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i1;
import 'package:serverpod_database/serverpod_database.dart' as _i2;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i3;
import 'package:serverpod_database/serverpod_database.dart' as _isd;
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
as _icw2tu00;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// CRDT visibility generation table.
///
/// This table stores materialized monotone CLFlag metadata after a visibility
/// change event has been recorded.
abstract class CrdtDataDeleted extends _i1.BaseHlc
implements _i2.TableRow<int?>, _i3.ProtocolSerialization {
abstract class CrdtDataDeleted extends _icw2tu00.BaseHlc
implements _isd.TableRow<int?>, _iss.ProtocolSerialization {
CrdtDataDeleted._({
this.id,
required super.hlcDatetime,
@ -37,33 +38,35 @@ abstract class CrdtDataDeleted extends _i1.BaseHlc
int? id,
required DateTime hlcDatetime,
required int hlcCounter,
_i1.CrdtDataRow? row,
_icw2tu00.CrdtDataRow? row,
required int rowId,
required int nodeId,
_i1.CrdtNode? node,
_icw2tu00.CrdtNode? node,
required int clFlag,
required _i1.CrdtDataDeletedReason reason,
required _icw2tu00.CrdtDataDeletedReason reason,
}) = _CrdtDataDeletedImpl;
factory CrdtDataDeleted.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtDataDeleted(
id: jsonSerialization['id'] as int?,
hlcDatetime: _i3.DateTimeJsonExtension.fromJson(
hlcDatetime: _iss.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
row: jsonSerialization['row'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtDataRow>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtDataRow>(
jsonSerialization['row'],
),
rowId: jsonSerialization['rowId'] as int,
nodeId: jsonSerialization['nodeId'] as int,
node: jsonSerialization['node'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtNode>(jsonSerialization['node']),
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtNode>(
jsonSerialization['node'],
),
clFlag: jsonSerialization['clFlag'] as int,
reason: _i1.CrdtDataDeletedReason.fromJson(
reason: _icw2tu00.CrdtDataDeletedReason.fromJson(
(jsonSerialization['reason'] as int),
),
);
@ -77,38 +80,38 @@ abstract class CrdtDataDeleted extends _i1.BaseHlc
int? id;
/// Row whose visibility is tracked.
_i1.CrdtDataRow? row;
_icw2tu00.CrdtDataRow? row;
int rowId;
int nodeId;
/// The node that updated the field.
_i1.CrdtNode? node;
_icw2tu00.CrdtNode? node;
/// Monotone causal-length flag. Odd values are visible and even values are deleted.
int clFlag;
/// Why the row entered its current visibility generation.
_i1.CrdtDataDeletedReason reason;
_icw2tu00.CrdtDataDeletedReason reason;
@override
_i2.Table<int?> get table => t;
_isd.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtDataDeleted]
/// with some or all fields replaced by the given arguments.
@override
@_i3.useResult
@_iss.useResult
CrdtDataDeleted copyWith({
int? id,
DateTime? hlcDatetime,
int? hlcCounter,
_i1.CrdtDataRow? row,
_icw2tu00.CrdtDataRow? row,
int? rowId,
int? nodeId,
_i1.CrdtNode? node,
_icw2tu00.CrdtNode? node,
int? clFlag,
_i1.CrdtDataDeletedReason? reason,
_icw2tu00.CrdtDataDeletedReason? reason,
});
@override
Map<String, dynamic> toJson() {
@ -143,8 +146,8 @@ abstract class CrdtDataDeleted extends _i1.BaseHlc
}
static CrdtDataDeletedInclude include({
_i1.CrdtDataRowInclude? row,
_i1.CrdtNodeInclude? node,
_icw2tu00.CrdtDataRowInclude? row,
_icw2tu00.CrdtNodeInclude? node,
}) {
return CrdtDataDeletedInclude._(
row: row,
@ -153,11 +156,11 @@ abstract class CrdtDataDeleted extends _i1.BaseHlc
}
static CrdtDataDeletedIncludeList includeList({
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
_isd.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_isd.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
CrdtDataDeletedInclude? include,
}) {
return CrdtDataDeletedIncludeList._(
@ -172,7 +175,7 @@ abstract class CrdtDataDeleted extends _i1.BaseHlc
@override
String toString() {
return _i3.SerializationManager.encode(this);
return _iss.SerializationManager.encode(this);
}
}
@ -183,12 +186,12 @@ class _CrdtDataDeletedImpl extends CrdtDataDeleted {
int? id,
required DateTime hlcDatetime,
required int hlcCounter,
_i1.CrdtDataRow? row,
_icw2tu00.CrdtDataRow? row,
required int rowId,
required int nodeId,
_i1.CrdtNode? node,
_icw2tu00.CrdtNode? node,
required int clFlag,
required _i1.CrdtDataDeletedReason reason,
required _icw2tu00.CrdtDataDeletedReason reason,
}) : super._(
id: id,
hlcDatetime: hlcDatetime,
@ -203,7 +206,7 @@ class _CrdtDataDeletedImpl extends CrdtDataDeleted {
/// Returns a shallow copy of this [CrdtDataDeleted]
/// with some or all fields replaced by the given arguments.
@_i3.useResult
@_iss.useResult
@override
CrdtDataDeleted copyWith({
Object? id = _Undefined,
@ -214,142 +217,145 @@ class _CrdtDataDeletedImpl extends CrdtDataDeleted {
int? nodeId,
Object? node = _Undefined,
int? clFlag,
_i1.CrdtDataDeletedReason? reason,
_icw2tu00.CrdtDataDeletedReason? reason,
}) {
return CrdtDataDeleted(
id: id is int? ? id : this.id,
hlcDatetime: hlcDatetime ?? this.hlcDatetime,
hlcCounter: hlcCounter ?? this.hlcCounter,
row: row is _i1.CrdtDataRow? ? row : this.row?.copyWith(),
row: row is _icw2tu00.CrdtDataRow? ? row : this.row?.copyWith(),
rowId: rowId ?? this.rowId,
nodeId: nodeId ?? this.nodeId,
node: node is _i1.CrdtNode? ? node : this.node?.copyWith(),
node: node is _icw2tu00.CrdtNode? ? node : this.node?.copyWith(),
clFlag: clFlag ?? this.clFlag,
reason: reason ?? this.reason,
);
}
}
class CrdtDataDeletedUpdateTable extends _i2.UpdateTable<CrdtDataDeletedTable> {
class CrdtDataDeletedUpdateTable
extends _isd.UpdateTable<CrdtDataDeletedTable> {
CrdtDataDeletedUpdateTable(super.table);
_i2.ColumnValue<DateTime, DateTime> hlcDatetime(DateTime value) =>
_i2.ColumnValue(
_isd.ColumnValue<DateTime, DateTime> hlcDatetime(DateTime value) =>
_isd.ColumnValue(
table.hlcDatetime,
value,
);
_i2.ColumnValue<int, int> hlcCounter(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> hlcCounter(int value) => _isd.ColumnValue(
table.hlcCounter,
value,
);
_i2.ColumnValue<int, int> rowId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> rowId(int value) => _isd.ColumnValue(
table.rowId,
value,
);
_i2.ColumnValue<int, int> nodeId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> nodeId(int value) => _isd.ColumnValue(
table.nodeId,
value,
);
_i2.ColumnValue<int, int> clFlag(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> clFlag(int value) => _isd.ColumnValue(
table.clFlag,
value,
);
_i2.ColumnValue<_i1.CrdtDataDeletedReason, _i1.CrdtDataDeletedReason> reason(
_i1.CrdtDataDeletedReason value,
) => _i2.ColumnValue(
_isd.ColumnValue<
_icw2tu00.CrdtDataDeletedReason,
_icw2tu00.CrdtDataDeletedReason
>
reason(_icw2tu00.CrdtDataDeletedReason value) => _isd.ColumnValue(
table.reason,
value,
);
}
class CrdtDataDeletedTable extends _i2.Table<int?> {
class CrdtDataDeletedTable extends _isd.Table<int?> {
CrdtDataDeletedTable({super.tableRelation})
: super(tableName: 'crdt_data_tombstone') {
updateTable = CrdtDataDeletedUpdateTable(this);
hlcDatetime = _i2.ColumnDateTime(
hlcDatetime = _isd.ColumnDateTime(
'hlcDatetime',
this,
);
hlcCounter = _i2.ColumnInt(
hlcCounter = _isd.ColumnInt(
'hlcCounter',
this,
);
rowId = _i2.ColumnInt(
rowId = _isd.ColumnInt(
'rowId',
this,
);
nodeId = _i2.ColumnInt(
nodeId = _isd.ColumnInt(
'nodeId',
this,
);
clFlag = _i2.ColumnInt(
clFlag = _isd.ColumnInt(
'clFlag',
this,
);
reason = _i2.ColumnEnum(
reason = _isd.ColumnEnum(
'reason',
this,
_i2.EnumSerialization.byIndex,
_isd.EnumSerialization.byIndex,
);
}
late final CrdtDataDeletedUpdateTable updateTable;
/// The datetime component of the HLC timestamp.
late final _i2.ColumnDateTime hlcDatetime;
late final _isd.ColumnDateTime hlcDatetime;
/// The counter component of the HLC timestamp.
late final _i2.ColumnInt hlcCounter;
late final _isd.ColumnInt hlcCounter;
/// Row whose visibility is tracked.
_i1.CrdtDataRowTable? _row;
_icw2tu00.CrdtDataRowTable? _row;
late final _i2.ColumnInt rowId;
late final _isd.ColumnInt rowId;
late final _i2.ColumnInt nodeId;
late final _isd.ColumnInt nodeId;
/// The node that updated the field.
_i1.CrdtNodeTable? _node;
_icw2tu00.CrdtNodeTable? _node;
/// Monotone causal-length flag. Odd values are visible and even values are deleted.
late final _i2.ColumnInt clFlag;
late final _isd.ColumnInt clFlag;
/// Why the row entered its current visibility generation.
late final _i2.ColumnEnum<_i1.CrdtDataDeletedReason> reason;
late final _isd.ColumnEnum<_icw2tu00.CrdtDataDeletedReason> reason;
_i1.CrdtDataRowTable get row {
_icw2tu00.CrdtDataRowTable get row {
if (_row != null) return _row!;
_row = _i2.createRelationTable(
_row = _isd.createRelationTable(
relationFieldName: 'row',
field: CrdtDataDeleted.t.rowId,
foreignField: _i1.CrdtDataRow.t.id,
foreignField: _icw2tu00.CrdtDataRow.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtDataRowTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtDataRowTable(tableRelation: foreignTableRelation),
);
return _row!;
}
_i1.CrdtNodeTable get node {
_icw2tu00.CrdtNodeTable get node {
if (_node != null) return _node!;
_node = _i2.createRelationTable(
_node = _isd.createRelationTable(
relationFieldName: 'node',
field: CrdtDataDeleted.t.nodeId,
foreignField: _i1.CrdtNode.t.id,
foreignField: _icw2tu00.CrdtNode.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtNodeTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtNodeTable(tableRelation: foreignTableRelation),
);
return _node!;
}
@override
List<_i2.Column> get columns => [
List<_isd.Column> get columns => [
id,
hlcDatetime,
hlcCounter,
@ -360,7 +366,7 @@ class CrdtDataDeletedTable extends _i2.Table<int?> {
];
@override
_i2.Table? getRelationTable(String relationField) {
_isd.Table? getRelationTable(String relationField) {
if (relationField == 'row') {
return row;
}
@ -371,32 +377,32 @@ class CrdtDataDeletedTable extends _i2.Table<int?> {
}
}
class CrdtDataDeletedInclude extends _i2.IncludeObject {
class CrdtDataDeletedInclude extends _isd.IncludeObject {
CrdtDataDeletedInclude._({
_i1.CrdtDataRowInclude? row,
_i1.CrdtNodeInclude? node,
_icw2tu00.CrdtDataRowInclude? row,
_icw2tu00.CrdtNodeInclude? node,
}) {
_row = row;
_node = node;
}
_i1.CrdtDataRowInclude? _row;
_icw2tu00.CrdtDataRowInclude? _row;
_i1.CrdtNodeInclude? _node;
_icw2tu00.CrdtNodeInclude? _node;
@override
Map<String, _i2.Include?> get includes => {
Map<String, _isd.Include?> get includes => {
'row': _row,
'node': _node,
};
@override
_i2.Table<int?> get table => CrdtDataDeleted.t;
_isd.Table<int?> get table => CrdtDataDeleted.t;
}
class CrdtDataDeletedIncludeList extends _i2.IncludeList {
class CrdtDataDeletedIncludeList extends _isd.IncludeList {
CrdtDataDeletedIncludeList._({
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
_isd.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
super.limit,
super.offset,
super.orderBy,
@ -407,10 +413,10 @@ class CrdtDataDeletedIncludeList extends _i2.IncludeList {
}
@override
Map<String, _i2.Include?> get includes => include?.includes ?? {};
Map<String, _isd.Include?> get includes => include?.includes ?? {};
@override
_i2.Table<int?> get table => CrdtDataDeleted.t;
_isd.Table<int?> get table => CrdtDataDeleted.t;
}
class CrdtDataDeletedRepository {
@ -441,16 +447,16 @@ class CrdtDataDeletedRepository {
/// );
/// ```
Future<List<CrdtDataDeleted>> find(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataDeletedInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtDataDeleted>(
where: where?.call(CrdtDataDeleted.t),
@ -483,15 +489,15 @@ class CrdtDataDeletedRepository {
/// );
/// ```
Future<CrdtDataDeleted?> findFirstRow(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataDeletedInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtDataDeleted>(
where: where?.call(CrdtDataDeleted.t),
@ -507,12 +513,12 @@ class CrdtDataDeletedRepository {
/// Finds a single [CrdtDataDeleted] by its [id] or null if no such row exists.
Future<CrdtDataDeleted?> findById(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
CrdtDataDeletedInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtDataDeleted>(
id,
@ -538,9 +544,9 @@ class CrdtDataDeletedRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> insert(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataDeleted> rows, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
@ -556,9 +562,9 @@ class CrdtDataDeletedRepository {
///
/// The returned [CrdtDataDeleted] will have its `id` field set.
Future<CrdtDataDeleted> insertRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataDeleted row, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtDataDeleted>(
row,
@ -587,12 +593,12 @@ class CrdtDataDeletedRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> upsert(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataDeleted> rows, {
required _i2.ColumnSelections<CrdtDataDeletedTable> conflictColumns,
_i2.ColumnSelections<CrdtDataDeletedTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? updateWhere,
_i2.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataDeletedTable> conflictColumns,
_isd.ColumnSelections<CrdtDataDeletedTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataDeletedTable>? updateWhere,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtDataDeleted>(
@ -619,12 +625,12 @@ class CrdtDataDeletedRepository {
///
/// The returned [CrdtDataDeleted] will have its `id` field set.
Future<CrdtDataDeleted?> upsertRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataDeleted row, {
required _i2.ColumnSelections<CrdtDataDeletedTable> conflictColumns,
_i2.ColumnSelections<CrdtDataDeletedTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? updateWhere,
_i2.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataDeletedTable> conflictColumns,
_isd.ColumnSelections<CrdtDataDeletedTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataDeletedTable>? updateWhere,
_isd.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtDataDeleted>(
row,
@ -645,10 +651,10 @@ class CrdtDataDeletedRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> update(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataDeleted> rows, {
_i2.ColumnSelections<CrdtDataDeletedTable>? columns,
_i2.Transaction? transaction,
_isd.ColumnSelections<CrdtDataDeletedTable>? columns,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtDataDeleted>(
@ -663,10 +669,10 @@ class CrdtDataDeletedRepository {
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtDataDeleted> updateRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataDeleted row, {
_i2.ColumnSelections<CrdtDataDeletedTable>? columns,
_i2.Transaction? transaction,
_isd.ColumnSelections<CrdtDataDeletedTable>? columns,
_isd.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtDataDeleted>(
row,
@ -678,11 +684,11 @@ class CrdtDataDeletedRepository {
/// Updates a single [CrdtDataDeleted] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtDataDeleted?> updateById(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
required _i2.ColumnValueListBuilder<CrdtDataDeletedUpdateTable>
required _isd.ColumnValueListBuilder<CrdtDataDeletedUpdateTable>
columnValues,
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.updateById<CrdtDataDeleted>(
id,
@ -698,15 +704,15 @@ class CrdtDataDeletedRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> updateWhere(
_i2.DatabaseSession session, {
required _i2.ColumnValueListBuilder<CrdtDataDeletedUpdateTable>
_isd.DatabaseSession session, {
required _isd.ColumnValueListBuilder<CrdtDataDeletedUpdateTable>
columnValues,
required _i2.WhereExpressionBuilder<CrdtDataDeletedTable> where,
required _isd.WhereExpressionBuilder<CrdtDataDeletedTable> where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtDataDeleted>(
@ -733,11 +739,11 @@ class CrdtDataDeletedRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> delete(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataDeleted> rows, {
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtDataDeleted>(
@ -751,9 +757,9 @@ class CrdtDataDeletedRepository {
/// Deletes a single [CrdtDataDeleted].
Future<CrdtDataDeleted> deleteRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataDeleted row, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtDataDeleted>(
row,
@ -770,11 +776,11 @@ class CrdtDataDeletedRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataDeleted>> deleteWhere(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataDeletedTable> where,
_i2.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_i2.Transaction? transaction,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataDeletedTable> where,
_isd.OrderByBuilder<CrdtDataDeletedTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataDeletedTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtDataDeleted>(
@ -789,10 +795,10 @@ class CrdtDataDeletedRepository {
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataDeletedTable>? where,
int? limit,
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.count<CrdtDataDeleted>(
where: where?.call(CrdtDataDeleted.t),
@ -803,11 +809,11 @@ class CrdtDataDeletedRepository {
/// Acquires row-level locks on [CrdtDataDeleted] rows matching the [where] expression.
Future<void> lockRows(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataDeletedTable> where,
required _i2.LockMode lockMode,
required _i2.Transaction transaction,
_i2.LockBehavior lockBehavior = _i2.LockBehavior.wait,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataDeletedTable> where,
required _isd.LockMode lockMode,
required _isd.Transaction transaction,
_isd.LockBehavior lockBehavior = _isd.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtDataDeleted>(
where: where(CrdtDataDeleted.t),
@ -824,10 +830,10 @@ class CrdtDataDeletedAttachRowRepository {
/// Creates a relation between the given [CrdtDataDeleted] and [CrdtDataRow]
/// by setting the [CrdtDataDeleted]'s foreign key `rowId` to refer to the [CrdtDataRow].
Future<void> row(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataDeleted crdtDataDeleted,
_i1.CrdtDataRow row, {
_i2.Transaction? transaction,
_icw2tu00.CrdtDataRow row, {
_isd.Transaction? transaction,
}) async {
if (crdtDataDeleted.id == null) {
throw ArgumentError.notNull('crdtDataDeleted.id');
@ -847,10 +853,10 @@ class CrdtDataDeletedAttachRowRepository {
/// Creates a relation between the given [CrdtDataDeleted] and [CrdtNode]
/// by setting the [CrdtDataDeleted]'s foreign key `nodeId` to refer to the [CrdtNode].
Future<void> node(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataDeleted crdtDataDeleted,
_i1.CrdtNode node, {
_i2.Transaction? transaction,
_icw2tu00.CrdtNode node, {
_isd.Transaction? transaction,
}) async {
if (crdtDataDeleted.id == null) {
throw ArgumentError.notNull('crdtDataDeleted.id');

View file

@ -10,10 +10,10 @@
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i1;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// Why a synced user tombstone changed row visibility.
enum CrdtDataDeletedReason implements _i1.SerializableModel {
enum CrdtDataDeletedReason implements _iss.SerializableModel {
userInsert,
userReinsert,
userDelete,

View file

@ -11,16 +11,17 @@
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i1;
import 'package:serverpod_database/serverpod_database.dart' as _i2;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i3;
import 'package:serverpod_database/serverpod_database.dart' as _isd;
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
as _icw2tu00;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// CRDT data table.
///
/// This table stores only the HLC timestamp for a field. During merge, if the
/// other HLC is greater, the actual data must be fetched from the table itself.
abstract class CrdtDataField extends _i1.BaseHlc
implements _i2.TableRow<int?>, _i3.ProtocolSerialization {
abstract class CrdtDataField extends _icw2tu00.BaseHlc
implements _isd.TableRow<int?>, _iss.ProtocolSerialization {
CrdtDataField._({
this.id,
required super.hlcDatetime,
@ -39,40 +40,42 @@ abstract class CrdtDataField extends _i1.BaseHlc
required DateTime hlcDatetime,
required int hlcCounter,
required int rowId,
_i1.CrdtDataRow? row,
_icw2tu00.CrdtDataRow? row,
required int columnId,
_i1.CrdtSchemaColumn? column,
_icw2tu00.CrdtSchemaColumn? column,
required int nodeId,
_i1.CrdtNode? node,
_i1.CrdtDataForeignKey? foreignKey,
_icw2tu00.CrdtNode? node,
_icw2tu00.CrdtDataForeignKey? foreignKey,
}) = _CrdtDataFieldImpl;
factory CrdtDataField.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtDataField(
id: jsonSerialization['id'] as int?,
hlcDatetime: _i3.DateTimeJsonExtension.fromJson(
hlcDatetime: _iss.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
rowId: jsonSerialization['rowId'] as int,
row: jsonSerialization['row'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtDataRow>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtDataRow>(
jsonSerialization['row'],
),
columnId: jsonSerialization['columnId'] as int,
column: jsonSerialization['column'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtSchemaColumn>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtSchemaColumn>(
jsonSerialization['column'],
),
nodeId: jsonSerialization['nodeId'] as int,
node: jsonSerialization['node'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtNode>(jsonSerialization['node']),
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtNode>(
jsonSerialization['node'],
),
foreignKey: jsonSerialization['foreignKey'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtDataForeignKey>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtDataForeignKey>(
jsonSerialization['foreignKey'],
),
);
@ -88,40 +91,40 @@ abstract class CrdtDataField extends _i1.BaseHlc
int rowId;
/// Row that the field belongs to.
_i1.CrdtDataRow? row;
_icw2tu00.CrdtDataRow? row;
int columnId;
/// Column that the field belongs to.
_i1.CrdtSchemaColumn? column;
_icw2tu00.CrdtSchemaColumn? column;
int nodeId;
/// The node that updated the field.
_i1.CrdtNode? node;
_icw2tu00.CrdtNode? node;
/// The foreign key information for the field, if this field holds a
/// reference to another row.
_i1.CrdtDataForeignKey? foreignKey;
_icw2tu00.CrdtDataForeignKey? foreignKey;
@override
_i2.Table<int?> get table => t;
_isd.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtDataField]
/// with some or all fields replaced by the given arguments.
@override
@_i3.useResult
@_iss.useResult
CrdtDataField copyWith({
int? id,
DateTime? hlcDatetime,
int? hlcCounter,
int? rowId,
_i1.CrdtDataRow? row,
_icw2tu00.CrdtDataRow? row,
int? columnId,
_i1.CrdtSchemaColumn? column,
_icw2tu00.CrdtSchemaColumn? column,
int? nodeId,
_i1.CrdtNode? node,
_i1.CrdtDataForeignKey? foreignKey,
_icw2tu00.CrdtNode? node,
_icw2tu00.CrdtDataForeignKey? foreignKey,
});
@override
Map<String, dynamic> toJson() {
@ -158,10 +161,10 @@ abstract class CrdtDataField extends _i1.BaseHlc
}
static CrdtDataFieldInclude include({
_i1.CrdtDataRowInclude? row,
_i1.CrdtSchemaColumnInclude? column,
_i1.CrdtNodeInclude? node,
_i1.CrdtDataForeignKeyInclude? foreignKey,
_icw2tu00.CrdtDataRowInclude? row,
_icw2tu00.CrdtSchemaColumnInclude? column,
_icw2tu00.CrdtNodeInclude? node,
_icw2tu00.CrdtDataForeignKeyInclude? foreignKey,
}) {
return CrdtDataFieldInclude._(
row: row,
@ -172,11 +175,11 @@ abstract class CrdtDataField extends _i1.BaseHlc
}
static CrdtDataFieldIncludeList includeList({
_i2.WhereExpressionBuilder<CrdtDataFieldTable>? where,
_isd.WhereExpressionBuilder<CrdtDataFieldTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_isd.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
CrdtDataFieldInclude? include,
}) {
return CrdtDataFieldIncludeList._(
@ -191,7 +194,7 @@ abstract class CrdtDataField extends _i1.BaseHlc
@override
String toString() {
return _i3.SerializationManager.encode(this);
return _iss.SerializationManager.encode(this);
}
}
@ -203,12 +206,12 @@ class _CrdtDataFieldImpl extends CrdtDataField {
required DateTime hlcDatetime,
required int hlcCounter,
required int rowId,
_i1.CrdtDataRow? row,
_icw2tu00.CrdtDataRow? row,
required int columnId,
_i1.CrdtSchemaColumn? column,
_icw2tu00.CrdtSchemaColumn? column,
required int nodeId,
_i1.CrdtNode? node,
_i1.CrdtDataForeignKey? foreignKey,
_icw2tu00.CrdtNode? node,
_icw2tu00.CrdtDataForeignKey? foreignKey,
}) : super._(
id: id,
hlcDatetime: hlcDatetime,
@ -224,7 +227,7 @@ class _CrdtDataFieldImpl extends CrdtDataField {
/// Returns a shallow copy of this [CrdtDataField]
/// with some or all fields replaced by the given arguments.
@_i3.useResult
@_iss.useResult
@override
CrdtDataField copyWith({
Object? id = _Undefined,
@ -243,71 +246,71 @@ class _CrdtDataFieldImpl extends CrdtDataField {
hlcDatetime: hlcDatetime ?? this.hlcDatetime,
hlcCounter: hlcCounter ?? this.hlcCounter,
rowId: rowId ?? this.rowId,
row: row is _i1.CrdtDataRow? ? row : this.row?.copyWith(),
row: row is _icw2tu00.CrdtDataRow? ? row : this.row?.copyWith(),
columnId: columnId ?? this.columnId,
column: column is _i1.CrdtSchemaColumn?
column: column is _icw2tu00.CrdtSchemaColumn?
? column
: this.column?.copyWith(),
nodeId: nodeId ?? this.nodeId,
node: node is _i1.CrdtNode? ? node : this.node?.copyWith(),
foreignKey: foreignKey is _i1.CrdtDataForeignKey?
node: node is _icw2tu00.CrdtNode? ? node : this.node?.copyWith(),
foreignKey: foreignKey is _icw2tu00.CrdtDataForeignKey?
? foreignKey
: this.foreignKey?.copyWith(),
);
}
}
class CrdtDataFieldUpdateTable extends _i2.UpdateTable<CrdtDataFieldTable> {
class CrdtDataFieldUpdateTable extends _isd.UpdateTable<CrdtDataFieldTable> {
CrdtDataFieldUpdateTable(super.table);
_i2.ColumnValue<DateTime, DateTime> hlcDatetime(DateTime value) =>
_i2.ColumnValue(
_isd.ColumnValue<DateTime, DateTime> hlcDatetime(DateTime value) =>
_isd.ColumnValue(
table.hlcDatetime,
value,
);
_i2.ColumnValue<int, int> hlcCounter(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> hlcCounter(int value) => _isd.ColumnValue(
table.hlcCounter,
value,
);
_i2.ColumnValue<int, int> rowId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> rowId(int value) => _isd.ColumnValue(
table.rowId,
value,
);
_i2.ColumnValue<int, int> columnId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> columnId(int value) => _isd.ColumnValue(
table.columnId,
value,
);
_i2.ColumnValue<int, int> nodeId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> nodeId(int value) => _isd.ColumnValue(
table.nodeId,
value,
);
}
class CrdtDataFieldTable extends _i2.Table<int?> {
class CrdtDataFieldTable extends _isd.Table<int?> {
CrdtDataFieldTable({super.tableRelation})
: super(tableName: 'crdt_data_fields') {
updateTable = CrdtDataFieldUpdateTable(this);
hlcDatetime = _i2.ColumnDateTime(
hlcDatetime = _isd.ColumnDateTime(
'hlcDatetime',
this,
);
hlcCounter = _i2.ColumnInt(
hlcCounter = _isd.ColumnInt(
'hlcCounter',
this,
);
rowId = _i2.ColumnInt(
rowId = _isd.ColumnInt(
'rowId',
this,
);
columnId = _i2.ColumnInt(
columnId = _isd.ColumnInt(
'columnId',
this,
);
nodeId = _i2.ColumnInt(
nodeId = _isd.ColumnInt(
'nodeId',
this,
);
@ -316,84 +319,85 @@ class CrdtDataFieldTable extends _i2.Table<int?> {
late final CrdtDataFieldUpdateTable updateTable;
/// The datetime component of the HLC timestamp.
late final _i2.ColumnDateTime hlcDatetime;
late final _isd.ColumnDateTime hlcDatetime;
/// The counter component of the HLC timestamp.
late final _i2.ColumnInt hlcCounter;
late final _isd.ColumnInt hlcCounter;
late final _i2.ColumnInt rowId;
late final _isd.ColumnInt rowId;
/// Row that the field belongs to.
_i1.CrdtDataRowTable? _row;
_icw2tu00.CrdtDataRowTable? _row;
late final _i2.ColumnInt columnId;
late final _isd.ColumnInt columnId;
/// Column that the field belongs to.
_i1.CrdtSchemaColumnTable? _column;
_icw2tu00.CrdtSchemaColumnTable? _column;
late final _i2.ColumnInt nodeId;
late final _isd.ColumnInt nodeId;
/// The node that updated the field.
_i1.CrdtNodeTable? _node;
_icw2tu00.CrdtNodeTable? _node;
/// The foreign key information for the field, if this field holds a
/// reference to another row.
_i1.CrdtDataForeignKeyTable? _foreignKey;
_icw2tu00.CrdtDataForeignKeyTable? _foreignKey;
_i1.CrdtDataRowTable get row {
_icw2tu00.CrdtDataRowTable get row {
if (_row != null) return _row!;
_row = _i2.createRelationTable(
_row = _isd.createRelationTable(
relationFieldName: 'row',
field: CrdtDataField.t.rowId,
foreignField: _i1.CrdtDataRow.t.id,
foreignField: _icw2tu00.CrdtDataRow.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtDataRowTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtDataRowTable(tableRelation: foreignTableRelation),
);
return _row!;
}
_i1.CrdtSchemaColumnTable get column {
_icw2tu00.CrdtSchemaColumnTable get column {
if (_column != null) return _column!;
_column = _i2.createRelationTable(
_column = _isd.createRelationTable(
relationFieldName: 'column',
field: CrdtDataField.t.columnId,
foreignField: _i1.CrdtSchemaColumn.t.id,
foreignField: _icw2tu00.CrdtSchemaColumn.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtSchemaColumnTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtSchemaColumnTable(tableRelation: foreignTableRelation),
);
return _column!;
}
_i1.CrdtNodeTable get node {
_icw2tu00.CrdtNodeTable get node {
if (_node != null) return _node!;
_node = _i2.createRelationTable(
_node = _isd.createRelationTable(
relationFieldName: 'node',
field: CrdtDataField.t.nodeId,
foreignField: _i1.CrdtNode.t.id,
foreignField: _icw2tu00.CrdtNode.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtNodeTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtNodeTable(tableRelation: foreignTableRelation),
);
return _node!;
}
_i1.CrdtDataForeignKeyTable get foreignKey {
_icw2tu00.CrdtDataForeignKeyTable get foreignKey {
if (_foreignKey != null) return _foreignKey!;
_foreignKey = _i2.createRelationTable(
_foreignKey = _isd.createRelationTable(
relationFieldName: 'foreignKey',
field: CrdtDataField.t.id,
foreignField: _i1.CrdtDataForeignKey.t.fieldId,
foreignField: _icw2tu00.CrdtDataForeignKey.t.fieldId,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtDataForeignKeyTable(tableRelation: foreignTableRelation),
createTable: (foreignTableRelation) => _icw2tu00.CrdtDataForeignKeyTable(
tableRelation: foreignTableRelation,
),
);
return _foreignKey!;
}
@override
List<_i2.Column> get columns => [
List<_isd.Column> get columns => [
id,
hlcDatetime,
hlcCounter,
@ -403,7 +407,7 @@ class CrdtDataFieldTable extends _i2.Table<int?> {
];
@override
_i2.Table? getRelationTable(String relationField) {
_isd.Table? getRelationTable(String relationField) {
if (relationField == 'row') {
return row;
}
@ -420,12 +424,12 @@ class CrdtDataFieldTable extends _i2.Table<int?> {
}
}
class CrdtDataFieldInclude extends _i2.IncludeObject {
class CrdtDataFieldInclude extends _isd.IncludeObject {
CrdtDataFieldInclude._({
_i1.CrdtDataRowInclude? row,
_i1.CrdtSchemaColumnInclude? column,
_i1.CrdtNodeInclude? node,
_i1.CrdtDataForeignKeyInclude? foreignKey,
_icw2tu00.CrdtDataRowInclude? row,
_icw2tu00.CrdtSchemaColumnInclude? column,
_icw2tu00.CrdtNodeInclude? node,
_icw2tu00.CrdtDataForeignKeyInclude? foreignKey,
}) {
_row = row;
_column = column;
@ -433,16 +437,16 @@ class CrdtDataFieldInclude extends _i2.IncludeObject {
_foreignKey = foreignKey;
}
_i1.CrdtDataRowInclude? _row;
_icw2tu00.CrdtDataRowInclude? _row;
_i1.CrdtSchemaColumnInclude? _column;
_icw2tu00.CrdtSchemaColumnInclude? _column;
_i1.CrdtNodeInclude? _node;
_icw2tu00.CrdtNodeInclude? _node;
_i1.CrdtDataForeignKeyInclude? _foreignKey;
_icw2tu00.CrdtDataForeignKeyInclude? _foreignKey;
@override
Map<String, _i2.Include?> get includes => {
Map<String, _isd.Include?> get includes => {
'row': _row,
'column': _column,
'node': _node,
@ -450,12 +454,12 @@ class CrdtDataFieldInclude extends _i2.IncludeObject {
};
@override
_i2.Table<int?> get table => CrdtDataField.t;
_isd.Table<int?> get table => CrdtDataField.t;
}
class CrdtDataFieldIncludeList extends _i2.IncludeList {
class CrdtDataFieldIncludeList extends _isd.IncludeList {
CrdtDataFieldIncludeList._({
_i2.WhereExpressionBuilder<CrdtDataFieldTable>? where,
_isd.WhereExpressionBuilder<CrdtDataFieldTable>? where,
super.limit,
super.offset,
super.orderBy,
@ -466,10 +470,10 @@ class CrdtDataFieldIncludeList extends _i2.IncludeList {
}
@override
Map<String, _i2.Include?> get includes => include?.includes ?? {};
Map<String, _isd.Include?> get includes => include?.includes ?? {};
@override
_i2.Table<int?> get table => CrdtDataField.t;
_isd.Table<int?> get table => CrdtDataField.t;
}
class CrdtDataFieldRepository {
@ -502,16 +506,16 @@ class CrdtDataFieldRepository {
/// );
/// ```
Future<List<CrdtDataField>> find(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataFieldTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataFieldTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataFieldInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtDataField>(
where: where?.call(CrdtDataField.t),
@ -544,15 +548,15 @@ class CrdtDataFieldRepository {
/// );
/// ```
Future<CrdtDataField?> findFirstRow(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataFieldTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataFieldTable>? where,
int? offset,
_i2.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataFieldInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtDataField>(
where: where?.call(CrdtDataField.t),
@ -568,12 +572,12 @@ class CrdtDataFieldRepository {
/// Finds a single [CrdtDataField] by its [id] or null if no such row exists.
Future<CrdtDataField?> findById(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
CrdtDataFieldInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtDataField>(
id,
@ -599,9 +603,9 @@ class CrdtDataFieldRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataField>> insert(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataField> rows, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
@ -617,9 +621,9 @@ class CrdtDataFieldRepository {
///
/// The returned [CrdtDataField] will have its `id` field set.
Future<CrdtDataField> insertRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField row, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtDataField>(
row,
@ -648,12 +652,12 @@ class CrdtDataFieldRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataField>> upsert(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataField> rows, {
required _i2.ColumnSelections<CrdtDataFieldTable> conflictColumns,
_i2.ColumnSelections<CrdtDataFieldTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataFieldTable>? updateWhere,
_i2.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataFieldTable> conflictColumns,
_isd.ColumnSelections<CrdtDataFieldTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataFieldTable>? updateWhere,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtDataField>(
@ -680,12 +684,12 @@ class CrdtDataFieldRepository {
///
/// The returned [CrdtDataField] will have its `id` field set.
Future<CrdtDataField?> upsertRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField row, {
required _i2.ColumnSelections<CrdtDataFieldTable> conflictColumns,
_i2.ColumnSelections<CrdtDataFieldTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataFieldTable>? updateWhere,
_i2.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataFieldTable> conflictColumns,
_isd.ColumnSelections<CrdtDataFieldTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataFieldTable>? updateWhere,
_isd.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtDataField>(
row,
@ -706,10 +710,10 @@ class CrdtDataFieldRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataField>> update(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataField> rows, {
_i2.ColumnSelections<CrdtDataFieldTable>? columns,
_i2.Transaction? transaction,
_isd.ColumnSelections<CrdtDataFieldTable>? columns,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtDataField>(
@ -724,10 +728,10 @@ class CrdtDataFieldRepository {
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtDataField> updateRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField row, {
_i2.ColumnSelections<CrdtDataFieldTable>? columns,
_i2.Transaction? transaction,
_isd.ColumnSelections<CrdtDataFieldTable>? columns,
_isd.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtDataField>(
row,
@ -739,10 +743,10 @@ class CrdtDataFieldRepository {
/// Updates a single [CrdtDataField] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtDataField?> updateById(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
required _i2.ColumnValueListBuilder<CrdtDataFieldUpdateTable> columnValues,
_i2.Transaction? transaction,
required _isd.ColumnValueListBuilder<CrdtDataFieldUpdateTable> columnValues,
_isd.Transaction? transaction,
}) async {
return session.db.updateById<CrdtDataField>(
id,
@ -758,14 +762,14 @@ class CrdtDataFieldRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataField>> updateWhere(
_i2.DatabaseSession session, {
required _i2.ColumnValueListBuilder<CrdtDataFieldUpdateTable> columnValues,
required _i2.WhereExpressionBuilder<CrdtDataFieldTable> where,
_isd.DatabaseSession session, {
required _isd.ColumnValueListBuilder<CrdtDataFieldUpdateTable> columnValues,
required _isd.WhereExpressionBuilder<CrdtDataFieldTable> where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtDataField>(
@ -792,11 +796,11 @@ class CrdtDataFieldRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataField>> delete(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataField> rows, {
_i2.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtDataField>(
@ -810,9 +814,9 @@ class CrdtDataFieldRepository {
/// Deletes a single [CrdtDataField].
Future<CrdtDataField> deleteRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField row, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtDataField>(
row,
@ -829,11 +833,11 @@ class CrdtDataFieldRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataField>> deleteWhere(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataFieldTable> where,
_i2.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_i2.Transaction? transaction,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataFieldTable> where,
_isd.OrderByBuilder<CrdtDataFieldTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataFieldTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtDataField>(
@ -848,10 +852,10 @@ class CrdtDataFieldRepository {
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataFieldTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataFieldTable>? where,
int? limit,
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.count<CrdtDataField>(
where: where?.call(CrdtDataField.t),
@ -862,11 +866,11 @@ class CrdtDataFieldRepository {
/// Acquires row-level locks on [CrdtDataField] rows matching the [where] expression.
Future<void> lockRows(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataFieldTable> where,
required _i2.LockMode lockMode,
required _i2.Transaction transaction,
_i2.LockBehavior lockBehavior = _i2.LockBehavior.wait,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataFieldTable> where,
required _isd.LockMode lockMode,
required _isd.Transaction transaction,
_isd.LockBehavior lockBehavior = _isd.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtDataField>(
where: where(CrdtDataField.t),
@ -883,10 +887,10 @@ class CrdtDataFieldAttachRowRepository {
/// Creates a relation between the given [CrdtDataField] and [CrdtDataRow]
/// by setting the [CrdtDataField]'s foreign key `rowId` to refer to the [CrdtDataRow].
Future<void> row(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField crdtDataField,
_i1.CrdtDataRow row, {
_i2.Transaction? transaction,
_icw2tu00.CrdtDataRow row, {
_isd.Transaction? transaction,
}) async {
if (crdtDataField.id == null) {
throw ArgumentError.notNull('crdtDataField.id');
@ -906,10 +910,10 @@ class CrdtDataFieldAttachRowRepository {
/// Creates a relation between the given [CrdtDataField] and [CrdtSchemaColumn]
/// by setting the [CrdtDataField]'s foreign key `columnId` to refer to the [CrdtSchemaColumn].
Future<void> column(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField crdtDataField,
_i1.CrdtSchemaColumn column, {
_i2.Transaction? transaction,
_icw2tu00.CrdtSchemaColumn column, {
_isd.Transaction? transaction,
}) async {
if (crdtDataField.id == null) {
throw ArgumentError.notNull('crdtDataField.id');
@ -929,10 +933,10 @@ class CrdtDataFieldAttachRowRepository {
/// Creates a relation between the given [CrdtDataField] and [CrdtNode]
/// by setting the [CrdtDataField]'s foreign key `nodeId` to refer to the [CrdtNode].
Future<void> node(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField crdtDataField,
_i1.CrdtNode node, {
_i2.Transaction? transaction,
_icw2tu00.CrdtNode node, {
_isd.Transaction? transaction,
}) async {
if (crdtDataField.id == null) {
throw ArgumentError.notNull('crdtDataField.id');
@ -952,10 +956,10 @@ class CrdtDataFieldAttachRowRepository {
/// Creates a relation between the given [CrdtDataField] and [CrdtDataForeignKey]
/// by setting the [CrdtDataField]'s foreign key `id` to refer to the [CrdtDataForeignKey].
Future<void> foreignKey(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField crdtDataField,
_i1.CrdtDataForeignKey foreignKey, {
_i2.Transaction? transaction,
_icw2tu00.CrdtDataForeignKey foreignKey, {
_isd.Transaction? transaction,
}) async {
if (foreignKey.id == null) {
throw ArgumentError.notNull('foreignKey.id');
@ -965,9 +969,9 @@ class CrdtDataFieldAttachRowRepository {
}
var $foreignKey = foreignKey.copyWith(fieldId: crdtDataField.id);
await session.db.updateRow<_i1.CrdtDataForeignKey>(
await session.db.updateRow<_icw2tu00.CrdtDataForeignKey>(
$foreignKey,
columns: [_i1.CrdtDataForeignKey.t.fieldId],
columns: [_icw2tu00.CrdtDataForeignKey.t.fieldId],
transaction: transaction,
);
}
@ -982,9 +986,9 @@ class CrdtDataFieldDetachRowRepository {
/// This removes the association between the two models without deleting
/// the related record.
Future<void> foreignKey(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataField crdtDataField, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
var $foreignKey = crdtDataField.foreignKey;
@ -999,9 +1003,9 @@ class CrdtDataFieldDetachRowRepository {
}
var $$foreignKey = $foreignKey.copyWith(fieldId: null);
await session.db.updateRow<_i1.CrdtDataForeignKey>(
await session.db.updateRow<_icw2tu00.CrdtDataForeignKey>(
$$foreignKey,
columns: [_i1.CrdtDataForeignKey.t.fieldId],
columns: [_icw2tu00.CrdtDataForeignKey.t.fieldId],
transaction: transaction,
);
}

View file

@ -11,9 +11,10 @@
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_database/serverpod_database.dart' as _i1;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i2;
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i3;
import 'package:serverpod_database/serverpod_database.dart' as _isd;
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
as _icw2tu00;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// CRDT field foreign key value and projection table.
///
@ -26,7 +27,7 @@ import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i3;
/// materialized into the domain row; they do not decide business semantics or
/// create user field updates during merge.
abstract class CrdtDataForeignKey
implements _i1.TableRow<int?>, _i2.ProtocolSerialization {
implements _isd.TableRow<int?>, _iss.ProtocolSerialization {
CrdtDataForeignKey._({
this.id,
this.field,
@ -38,11 +39,11 @@ abstract class CrdtDataForeignKey
factory CrdtDataForeignKey({
int? id,
_i3.CrdtDataField? field,
_icw2tu00.CrdtDataField? field,
required int fieldId,
required _i2.UuidValue? attemptedValue,
_i2.UuidValue? visibleValue,
_i3.CrdtForeignKeyOverrideReason? overrideReason,
required _iss.UuidValue? attemptedValue,
_iss.UuidValue? visibleValue,
_icw2tu00.CrdtForeignKeyOverrideReason? overrideReason,
}) = _CrdtDataForeignKeyImpl;
factory CrdtDataForeignKey.fromJson(Map<String, dynamic> jsonSerialization) {
@ -50,23 +51,23 @@ abstract class CrdtDataForeignKey
id: jsonSerialization['id'] as int?,
field: jsonSerialization['field'] == null
? null
: _i3.Protocol().deserialize<_i3.CrdtDataField>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtDataField>(
jsonSerialization['field'],
),
fieldId: jsonSerialization['fieldId'] as int,
attemptedValue: jsonSerialization['attemptedValue'] == null
? null
: _i2.UuidValueJsonExtension.fromJson(
: _iss.UuidValueJsonExtension.fromJson(
jsonSerialization['attemptedValue'],
),
visibleValue: jsonSerialization['visibleValue'] == null
? null
: _i2.UuidValueJsonExtension.fromJson(
: _iss.UuidValueJsonExtension.fromJson(
jsonSerialization['visibleValue'],
),
overrideReason: jsonSerialization['overrideReason'] == null
? null
: _i3.CrdtForeignKeyOverrideReason.fromJson(
: _icw2tu00.CrdtForeignKeyOverrideReason.fromJson(
(jsonSerialization['overrideReason'] as int),
),
);
@ -80,7 +81,7 @@ abstract class CrdtDataForeignKey
int? id;
/// The field that the foreign key belongs to.
_i3.CrdtDataField? field;
_icw2tu00.CrdtDataField? field;
int fieldId;
@ -88,11 +89,11 @@ abstract class CrdtDataForeignKey
///
/// This may be null for nullable foreign keys. This is durable FK field-value
/// storage for CRDT columns whose CrdtDataField row stores only HLC metadata.
_i2.UuidValue? attemptedValue;
_iss.UuidValue? attemptedValue;
/// The foreign key value that is currently visible in the actual data row
/// when an override is active (overrideReason is non-null).
_i2.UuidValue? visibleValue;
_iss.UuidValue? visibleValue;
/// The authoritative indicator and reason for an active projection override.
///
@ -100,21 +101,21 @@ abstract class CrdtDataForeignKey
/// non-null means an override is active; null means no override. It also
/// names the cause of the override. The FK resolver recomputes it from merged
/// row, field, and tombstone facts.
_i3.CrdtForeignKeyOverrideReason? overrideReason;
_icw2tu00.CrdtForeignKeyOverrideReason? overrideReason;
@override
_i1.Table<int?> get table => t;
_isd.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtDataForeignKey]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@_iss.useResult
CrdtDataForeignKey copyWith({
int? id,
_i3.CrdtDataField? field,
_icw2tu00.CrdtDataField? field,
int? fieldId,
_i2.UuidValue? attemptedValue,
_i2.UuidValue? visibleValue,
_i3.CrdtForeignKeyOverrideReason? overrideReason,
_iss.UuidValue? attemptedValue,
_iss.UuidValue? visibleValue,
_icw2tu00.CrdtForeignKeyOverrideReason? overrideReason,
});
@override
Map<String, dynamic> toJson() {
@ -142,16 +143,18 @@ abstract class CrdtDataForeignKey
};
}
static CrdtDataForeignKeyInclude include({_i3.CrdtDataFieldInclude? field}) {
static CrdtDataForeignKeyInclude include({
_icw2tu00.CrdtDataFieldInclude? field,
}) {
return CrdtDataForeignKeyInclude._(field: field);
}
static CrdtDataForeignKeyIncludeList includeList({
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
_isd.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_isd.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
CrdtDataForeignKeyInclude? include,
}) {
return CrdtDataForeignKeyIncludeList._(
@ -166,7 +169,7 @@ abstract class CrdtDataForeignKey
@override
String toString() {
return _i2.SerializationManager.encode(this);
return _iss.SerializationManager.encode(this);
}
}
@ -175,11 +178,11 @@ class _Undefined {}
class _CrdtDataForeignKeyImpl extends CrdtDataForeignKey {
_CrdtDataForeignKeyImpl({
int? id,
_i3.CrdtDataField? field,
_icw2tu00.CrdtDataField? field,
required int fieldId,
required _i2.UuidValue? attemptedValue,
_i2.UuidValue? visibleValue,
_i3.CrdtForeignKeyOverrideReason? overrideReason,
required _iss.UuidValue? attemptedValue,
_iss.UuidValue? visibleValue,
_icw2tu00.CrdtForeignKeyOverrideReason? overrideReason,
}) : super._(
id: id,
field: field,
@ -191,7 +194,7 @@ class _CrdtDataForeignKeyImpl extends CrdtDataForeignKey {
/// Returns a shallow copy of this [CrdtDataForeignKey]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@_iss.useResult
@override
CrdtDataForeignKey copyWith({
Object? id = _Undefined,
@ -203,15 +206,15 @@ class _CrdtDataForeignKeyImpl extends CrdtDataForeignKey {
}) {
return CrdtDataForeignKey(
id: id is int? ? id : this.id,
field: field is _i3.CrdtDataField? ? field : this.field?.copyWith(),
field: field is _icw2tu00.CrdtDataField? ? field : this.field?.copyWith(),
fieldId: fieldId ?? this.fieldId,
attemptedValue: attemptedValue is _i2.UuidValue?
attemptedValue: attemptedValue is _iss.UuidValue?
? attemptedValue
: this.attemptedValue,
visibleValue: visibleValue is _i2.UuidValue?
visibleValue: visibleValue is _iss.UuidValue?
? visibleValue
: this.visibleValue,
overrideReason: overrideReason is _i3.CrdtForeignKeyOverrideReason?
overrideReason: overrideReason is _icw2tu00.CrdtForeignKeyOverrideReason?
? overrideReason
: this.overrideReason,
);
@ -219,77 +222,78 @@ class _CrdtDataForeignKeyImpl extends CrdtDataForeignKey {
}
class CrdtDataForeignKeyUpdateTable
extends _i1.UpdateTable<CrdtDataForeignKeyTable> {
extends _isd.UpdateTable<CrdtDataForeignKeyTable> {
CrdtDataForeignKeyUpdateTable(super.table);
_i1.ColumnValue<int, int> fieldId(int value) => _i1.ColumnValue(
_isd.ColumnValue<int, int> fieldId(int value) => _isd.ColumnValue(
table.fieldId,
value,
);
_i1.ColumnValue<_i2.UuidValue, _i2.UuidValue> attemptedValue(
_i2.UuidValue? value,
) => _i1.ColumnValue(
_isd.ColumnValue<_iss.UuidValue, _iss.UuidValue> attemptedValue(
_iss.UuidValue? value,
) => _isd.ColumnValue(
table.attemptedValue,
value,
);
_i1.ColumnValue<_i2.UuidValue, _i2.UuidValue> visibleValue(
_i2.UuidValue? value,
) => _i1.ColumnValue(
_isd.ColumnValue<_iss.UuidValue, _iss.UuidValue> visibleValue(
_iss.UuidValue? value,
) => _isd.ColumnValue(
table.visibleValue,
value,
);
_i1.ColumnValue<
_i3.CrdtForeignKeyOverrideReason,
_i3.CrdtForeignKeyOverrideReason
_isd.ColumnValue<
_icw2tu00.CrdtForeignKeyOverrideReason,
_icw2tu00.CrdtForeignKeyOverrideReason
>
overrideReason(_i3.CrdtForeignKeyOverrideReason? value) => _i1.ColumnValue(
table.overrideReason,
value,
);
overrideReason(_icw2tu00.CrdtForeignKeyOverrideReason? value) =>
_isd.ColumnValue(
table.overrideReason,
value,
);
}
class CrdtDataForeignKeyTable extends _i1.Table<int?> {
class CrdtDataForeignKeyTable extends _isd.Table<int?> {
CrdtDataForeignKeyTable({super.tableRelation})
: super(tableName: 'crdt_data_foreign_key') {
updateTable = CrdtDataForeignKeyUpdateTable(this);
fieldId = _i1.ColumnInt(
fieldId = _isd.ColumnInt(
'fieldId',
this,
);
attemptedValue = _i1.ColumnUuid(
attemptedValue = _isd.ColumnUuid(
'attemptedValue',
this,
);
visibleValue = _i1.ColumnUuid(
visibleValue = _isd.ColumnUuid(
'visibleValue',
this,
);
overrideReason = _i1.ColumnEnum(
overrideReason = _isd.ColumnEnum(
'overrideReason',
this,
_i1.EnumSerialization.byIndex,
_isd.EnumSerialization.byIndex,
);
}
late final CrdtDataForeignKeyUpdateTable updateTable;
/// The field that the foreign key belongs to.
_i3.CrdtDataFieldTable? _field;
_icw2tu00.CrdtDataFieldTable? _field;
late final _i1.ColumnInt fieldId;
late final _isd.ColumnInt fieldId;
/// The user-attempted foreign key value that the CRDT field currently carries.
///
/// This may be null for nullable foreign keys. This is durable FK field-value
/// storage for CRDT columns whose CrdtDataField row stores only HLC metadata.
late final _i1.ColumnUuid attemptedValue;
late final _isd.ColumnUuid attemptedValue;
/// The foreign key value that is currently visible in the actual data row
/// when an override is active (overrideReason is non-null).
late final _i1.ColumnUuid visibleValue;
late final _isd.ColumnUuid visibleValue;
/// The authoritative indicator and reason for an active projection override.
///
@ -297,23 +301,24 @@ class CrdtDataForeignKeyTable extends _i1.Table<int?> {
/// non-null means an override is active; null means no override. It also
/// names the cause of the override. The FK resolver recomputes it from merged
/// row, field, and tombstone facts.
late final _i1.ColumnEnum<_i3.CrdtForeignKeyOverrideReason> overrideReason;
late final _isd.ColumnEnum<_icw2tu00.CrdtForeignKeyOverrideReason>
overrideReason;
_i3.CrdtDataFieldTable get field {
_icw2tu00.CrdtDataFieldTable get field {
if (_field != null) return _field!;
_field = _i1.createRelationTable(
_field = _isd.createRelationTable(
relationFieldName: 'field',
field: CrdtDataForeignKey.t.fieldId,
foreignField: _i3.CrdtDataField.t.id,
foreignField: _icw2tu00.CrdtDataField.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i3.CrdtDataFieldTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtDataFieldTable(tableRelation: foreignTableRelation),
);
return _field!;
}
@override
List<_i1.Column> get columns => [
List<_isd.Column> get columns => [
id,
fieldId,
attemptedValue,
@ -322,7 +327,7 @@ class CrdtDataForeignKeyTable extends _i1.Table<int?> {
];
@override
_i1.Table? getRelationTable(String relationField) {
_isd.Table? getRelationTable(String relationField) {
if (relationField == 'field') {
return field;
}
@ -330,23 +335,23 @@ class CrdtDataForeignKeyTable extends _i1.Table<int?> {
}
}
class CrdtDataForeignKeyInclude extends _i1.IncludeObject {
CrdtDataForeignKeyInclude._({_i3.CrdtDataFieldInclude? field}) {
class CrdtDataForeignKeyInclude extends _isd.IncludeObject {
CrdtDataForeignKeyInclude._({_icw2tu00.CrdtDataFieldInclude? field}) {
_field = field;
}
_i3.CrdtDataFieldInclude? _field;
_icw2tu00.CrdtDataFieldInclude? _field;
@override
Map<String, _i1.Include?> get includes => {'field': _field};
Map<String, _isd.Include?> get includes => {'field': _field};
@override
_i1.Table<int?> get table => CrdtDataForeignKey.t;
_isd.Table<int?> get table => CrdtDataForeignKey.t;
}
class CrdtDataForeignKeyIncludeList extends _i1.IncludeList {
class CrdtDataForeignKeyIncludeList extends _isd.IncludeList {
CrdtDataForeignKeyIncludeList._({
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
_isd.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
super.limit,
super.offset,
super.orderBy,
@ -357,10 +362,10 @@ class CrdtDataForeignKeyIncludeList extends _i1.IncludeList {
}
@override
Map<String, _i1.Include?> get includes => include?.includes ?? {};
Map<String, _isd.Include?> get includes => include?.includes ?? {};
@override
_i1.Table<int?> get table => CrdtDataForeignKey.t;
_isd.Table<int?> get table => CrdtDataForeignKey.t;
}
class CrdtDataForeignKeyRepository {
@ -391,16 +396,16 @@ class CrdtDataForeignKeyRepository {
/// );
/// ```
Future<List<CrdtDataForeignKey>> find(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataForeignKeyInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtDataForeignKey>(
where: where?.call(CrdtDataForeignKey.t),
@ -433,15 +438,15 @@ class CrdtDataForeignKeyRepository {
/// );
/// ```
Future<CrdtDataForeignKey?> findFirstRow(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataForeignKeyInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtDataForeignKey>(
where: where?.call(CrdtDataForeignKey.t),
@ -457,12 +462,12 @@ class CrdtDataForeignKeyRepository {
/// Finds a single [CrdtDataForeignKey] by its [id] or null if no such row exists.
Future<CrdtDataForeignKey?> findById(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
_i1.Transaction? transaction,
_isd.Transaction? transaction,
CrdtDataForeignKeyInclude? include,
_i1.LockMode? lockMode,
_i1.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtDataForeignKey>(
id,
@ -488,9 +493,9 @@ class CrdtDataForeignKeyRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> insert(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
_i1.Transaction? transaction,
_isd.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
@ -506,9 +511,9 @@ class CrdtDataForeignKeyRepository {
///
/// The returned [CrdtDataForeignKey] will have its `id` field set.
Future<CrdtDataForeignKey> insertRow(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataForeignKey row, {
_i1.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtDataForeignKey>(
row,
@ -537,12 +542,12 @@ class CrdtDataForeignKeyRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> upsert(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
required _i1.ColumnSelections<CrdtDataForeignKeyTable> conflictColumns,
_i1.ColumnSelections<CrdtDataForeignKeyTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? updateWhere,
_i1.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataForeignKeyTable> conflictColumns,
_isd.ColumnSelections<CrdtDataForeignKeyTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataForeignKeyTable>? updateWhere,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtDataForeignKey>(
@ -569,12 +574,12 @@ class CrdtDataForeignKeyRepository {
///
/// The returned [CrdtDataForeignKey] will have its `id` field set.
Future<CrdtDataForeignKey?> upsertRow(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataForeignKey row, {
required _i1.ColumnSelections<CrdtDataForeignKeyTable> conflictColumns,
_i1.ColumnSelections<CrdtDataForeignKeyTable>? updateColumns,
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? updateWhere,
_i1.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataForeignKeyTable> conflictColumns,
_isd.ColumnSelections<CrdtDataForeignKeyTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataForeignKeyTable>? updateWhere,
_isd.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtDataForeignKey>(
row,
@ -595,10 +600,10 @@ class CrdtDataForeignKeyRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> update(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
_i1.ColumnSelections<CrdtDataForeignKeyTable>? columns,
_i1.Transaction? transaction,
_isd.ColumnSelections<CrdtDataForeignKeyTable>? columns,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtDataForeignKey>(
@ -613,10 +618,10 @@ class CrdtDataForeignKeyRepository {
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtDataForeignKey> updateRow(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataForeignKey row, {
_i1.ColumnSelections<CrdtDataForeignKeyTable>? columns,
_i1.Transaction? transaction,
_isd.ColumnSelections<CrdtDataForeignKeyTable>? columns,
_isd.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtDataForeignKey>(
row,
@ -628,11 +633,11 @@ class CrdtDataForeignKeyRepository {
/// Updates a single [CrdtDataForeignKey] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtDataForeignKey?> updateById(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
required _i1.ColumnValueListBuilder<CrdtDataForeignKeyUpdateTable>
required _isd.ColumnValueListBuilder<CrdtDataForeignKeyUpdateTable>
columnValues,
_i1.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.updateById<CrdtDataForeignKey>(
id,
@ -648,15 +653,15 @@ class CrdtDataForeignKeyRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> updateWhere(
_i1.DatabaseSession session, {
required _i1.ColumnValueListBuilder<CrdtDataForeignKeyUpdateTable>
_isd.DatabaseSession session, {
required _isd.ColumnValueListBuilder<CrdtDataForeignKeyUpdateTable>
columnValues,
required _i1.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
required _isd.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
int? limit,
int? offset,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtDataForeignKey>(
@ -683,11 +688,11 @@ class CrdtDataForeignKeyRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> delete(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataForeignKey> rows, {
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtDataForeignKey>(
@ -701,9 +706,9 @@ class CrdtDataForeignKeyRepository {
/// Deletes a single [CrdtDataForeignKey].
Future<CrdtDataForeignKey> deleteRow(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataForeignKey row, {
_i1.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtDataForeignKey>(
row,
@ -720,11 +725,11 @@ class CrdtDataForeignKeyRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataForeignKey>> deleteWhere(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
_i1.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_i1.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_i1.Transaction? transaction,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
_isd.OrderByBuilder<CrdtDataForeignKeyTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataForeignKeyTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtDataForeignKey>(
@ -739,10 +744,10 @@ class CrdtDataForeignKeyRepository {
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i1.DatabaseSession session, {
_i1.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataForeignKeyTable>? where,
int? limit,
_i1.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.count<CrdtDataForeignKey>(
where: where?.call(CrdtDataForeignKey.t),
@ -753,11 +758,11 @@ class CrdtDataForeignKeyRepository {
/// Acquires row-level locks on [CrdtDataForeignKey] rows matching the [where] expression.
Future<void> lockRows(
_i1.DatabaseSession session, {
required _i1.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
required _i1.LockMode lockMode,
required _i1.Transaction transaction,
_i1.LockBehavior lockBehavior = _i1.LockBehavior.wait,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataForeignKeyTable> where,
required _isd.LockMode lockMode,
required _isd.Transaction transaction,
_isd.LockBehavior lockBehavior = _isd.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtDataForeignKey>(
where: where(CrdtDataForeignKey.t),
@ -774,10 +779,10 @@ class CrdtDataForeignKeyAttachRowRepository {
/// Creates a relation between the given [CrdtDataForeignKey] and [CrdtDataField]
/// by setting the [CrdtDataForeignKey]'s foreign key `fieldId` to refer to the [CrdtDataField].
Future<void> field(
_i1.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataForeignKey crdtDataForeignKey,
_i3.CrdtDataField field, {
_i1.Transaction? transaction,
_icw2tu00.CrdtDataField field, {
_isd.Transaction? transaction,
}) async {
if (crdtDataForeignKey.id == null) {
throw ArgumentError.notNull('crdtDataForeignKey.id');

View file

@ -10,10 +10,10 @@
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i1;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// Why a foreign key projection override is active.
enum CrdtForeignKeyOverrideReason implements _i1.SerializableModel {
enum CrdtForeignKeyOverrideReason implements _iss.SerializableModel {
/// The attempted parent target is hidden or missing and the FK projection
/// set the column to null.
setNull,

View file

@ -11,9 +11,10 @@
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i1;
import 'package:serverpod_database/serverpod_database.dart' as _i2;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i3;
import 'package:serverpod_database/serverpod_database.dart' as _isd;
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
as _icw2tu00;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// CRDT data rows table.
///
@ -22,8 +23,8 @@ import 'package:serverpod_serialization/serverpod_serialization.dart' as _i3;
///
/// The row is also the HLC timestamp for when it was inserted. This is used to
/// avoid creating one entry per field until a field is updated.
abstract class CrdtDataRow extends _i1.BaseHlc
implements _i2.TableRow<int?>, _i3.ProtocolSerialization {
abstract class CrdtDataRow extends _icw2tu00.BaseHlc
implements _isd.TableRow<int?>, _iss.ProtocolSerialization {
CrdtDataRow._({
this.id,
required super.hlcDatetime,
@ -35,66 +36,68 @@ abstract class CrdtDataRow extends _i1.BaseHlc
required this.uuidRowId,
required this.nodeId,
this.node,
_i1.CrdtDataRowVisibility? visibility,
_icw2tu00.CrdtDataRowVisibility? visibility,
this.deleted,
this.fields,
}) : visibility = visibility ?? _i1.CrdtDataRowVisibility.userInsert;
}) : visibility = visibility ?? _icw2tu00.CrdtDataRowVisibility.userInsert;
factory CrdtDataRow({
int? id,
required DateTime hlcDatetime,
required int hlcCounter,
required int scopeId,
_i1.CrdtScope? scope,
_icw2tu00.CrdtScope? scope,
required int tblId,
_i1.CrdtSchemaTable? tbl,
required _i3.UuidValue uuidRowId,
_icw2tu00.CrdtSchemaTable? tbl,
required _iss.UuidValue uuidRowId,
required int nodeId,
_i1.CrdtNode? node,
_i1.CrdtDataRowVisibility? visibility,
_i1.CrdtDataDeleted? deleted,
List<_i1.CrdtDataField>? fields,
_icw2tu00.CrdtNode? node,
_icw2tu00.CrdtDataRowVisibility? visibility,
_icw2tu00.CrdtDataDeleted? deleted,
List<_icw2tu00.CrdtDataField>? fields,
}) = _CrdtDataRowImpl;
factory CrdtDataRow.fromJson(Map<String, dynamic> jsonSerialization) {
return CrdtDataRow(
id: jsonSerialization['id'] as int?,
hlcDatetime: _i3.DateTimeJsonExtension.fromJson(
hlcDatetime: _iss.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
scopeId: jsonSerialization['scopeId'] as int,
scope: jsonSerialization['scope'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtScope>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtScope>(
jsonSerialization['scope'],
),
tblId: jsonSerialization['tblId'] as int,
tbl: jsonSerialization['tbl'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtSchemaTable>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtSchemaTable>(
jsonSerialization['tbl'],
),
uuidRowId: _i3.UuidValueJsonExtension.fromJson(
uuidRowId: _iss.UuidValueJsonExtension.fromJson(
jsonSerialization['uuidRowId'],
),
nodeId: jsonSerialization['nodeId'] as int,
node: jsonSerialization['node'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtNode>(jsonSerialization['node']),
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtNode>(
jsonSerialization['node'],
),
visibility: jsonSerialization['visibility'] == null
? null
: _i1.CrdtDataRowVisibility.fromJson(
: _icw2tu00.CrdtDataRowVisibility.fromJson(
(jsonSerialization['visibility'] as int),
),
deleted: jsonSerialization['deleted'] == null
? null
: _i1.Protocol().deserialize<_i1.CrdtDataDeleted>(
: _icw2tu00.Protocol().deserialize<_icw2tu00.CrdtDataDeleted>(
jsonSerialization['deleted'],
),
fields: jsonSerialization['fields'] == null
? null
: _i1.Protocol().deserialize<List<_i1.CrdtDataField>>(
: _icw2tu00.Protocol().deserialize<List<_icw2tu00.CrdtDataField>>(
jsonSerialization['fields'],
),
);
@ -110,57 +113,57 @@ abstract class CrdtDataRow extends _i1.BaseHlc
int scopeId;
/// Identifier for the scope that owns the data.
_i1.CrdtScope? scope;
_icw2tu00.CrdtScope? scope;
int tblId;
/// Reference to the table this row belongs to.
_i1.CrdtSchemaTable? tbl;
_icw2tu00.CrdtSchemaTable? tbl;
/// Row identifier.
_i3.UuidValue uuidRowId;
_iss.UuidValue uuidRowId;
int nodeId;
/// The node that inserted the row with the HLC timestamp.
_i1.CrdtNode? node;
_icw2tu00.CrdtNode? node;
/// Materialized visibility state for domain queries.
///
/// Updated by user tombstone writes and foreign key projection. Visible
/// states are listed before hidden states in CrdtDataRowVisibility.
_i1.CrdtDataRowVisibility visibility;
_icw2tu00.CrdtDataRowVisibility visibility;
/// The synced user tombstone for this row.
///
/// Only present after the first user visibility change event has been recorded.
/// Projection may keep a visible [visibility] while a user delete tombstone exists.
_i1.CrdtDataDeleted? deleted;
_icw2tu00.CrdtDataDeleted? deleted;
/// The fields for this row.
List<_i1.CrdtDataField>? fields;
List<_icw2tu00.CrdtDataField>? fields;
@override
_i2.Table<int?> get table => t;
_isd.Table<int?> get table => t;
/// Returns a shallow copy of this [CrdtDataRow]
/// with some or all fields replaced by the given arguments.
@override
@_i3.useResult
@_iss.useResult
CrdtDataRow copyWith({
int? id,
DateTime? hlcDatetime,
int? hlcCounter,
int? scopeId,
_i1.CrdtScope? scope,
_icw2tu00.CrdtScope? scope,
int? tblId,
_i1.CrdtSchemaTable? tbl,
_i3.UuidValue? uuidRowId,
_icw2tu00.CrdtSchemaTable? tbl,
_iss.UuidValue? uuidRowId,
int? nodeId,
_i1.CrdtNode? node,
_i1.CrdtDataRowVisibility? visibility,
_i1.CrdtDataDeleted? deleted,
List<_i1.CrdtDataField>? fields,
_icw2tu00.CrdtNode? node,
_icw2tu00.CrdtDataRowVisibility? visibility,
_icw2tu00.CrdtDataDeleted? deleted,
List<_icw2tu00.CrdtDataField>? fields,
});
@override
Map<String, dynamic> toJson() {
@ -205,11 +208,11 @@ abstract class CrdtDataRow extends _i1.BaseHlc
}
static CrdtDataRowInclude include({
_i1.CrdtScopeInclude? scope,
_i1.CrdtSchemaTableInclude? tbl,
_i1.CrdtNodeInclude? node,
_i1.CrdtDataDeletedInclude? deleted,
_i1.CrdtDataFieldIncludeList? fields,
_icw2tu00.CrdtScopeInclude? scope,
_icw2tu00.CrdtSchemaTableInclude? tbl,
_icw2tu00.CrdtNodeInclude? node,
_icw2tu00.CrdtDataDeletedInclude? deleted,
_icw2tu00.CrdtDataFieldIncludeList? fields,
}) {
return CrdtDataRowInclude._(
scope: scope,
@ -221,11 +224,11 @@ abstract class CrdtDataRow extends _i1.BaseHlc
}
static CrdtDataRowIncludeList includeList({
_i2.WhereExpressionBuilder<CrdtDataRowTable>? where,
_isd.WhereExpressionBuilder<CrdtDataRowTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataRowTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_isd.OrderByBuilder<CrdtDataRowTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataRowTable>? orderByList,
CrdtDataRowInclude? include,
}) {
return CrdtDataRowIncludeList._(
@ -240,7 +243,7 @@ abstract class CrdtDataRow extends _i1.BaseHlc
@override
String toString() {
return _i3.SerializationManager.encode(this);
return _iss.SerializationManager.encode(this);
}
}
@ -252,15 +255,15 @@ class _CrdtDataRowImpl extends CrdtDataRow {
required DateTime hlcDatetime,
required int hlcCounter,
required int scopeId,
_i1.CrdtScope? scope,
_icw2tu00.CrdtScope? scope,
required int tblId,
_i1.CrdtSchemaTable? tbl,
required _i3.UuidValue uuidRowId,
_icw2tu00.CrdtSchemaTable? tbl,
required _iss.UuidValue uuidRowId,
required int nodeId,
_i1.CrdtNode? node,
_i1.CrdtDataRowVisibility? visibility,
_i1.CrdtDataDeleted? deleted,
List<_i1.CrdtDataField>? fields,
_icw2tu00.CrdtNode? node,
_icw2tu00.CrdtDataRowVisibility? visibility,
_icw2tu00.CrdtDataDeleted? deleted,
List<_icw2tu00.CrdtDataField>? fields,
}) : super._(
id: id,
hlcDatetime: hlcDatetime,
@ -279,7 +282,7 @@ class _CrdtDataRowImpl extends CrdtDataRow {
/// Returns a shallow copy of this [CrdtDataRow]
/// with some or all fields replaced by the given arguments.
@_i3.useResult
@_iss.useResult
@override
CrdtDataRow copyWith({
Object? id = _Undefined,
@ -289,10 +292,10 @@ class _CrdtDataRowImpl extends CrdtDataRow {
Object? scope = _Undefined,
int? tblId,
Object? tbl = _Undefined,
_i3.UuidValue? uuidRowId,
_iss.UuidValue? uuidRowId,
int? nodeId,
Object? node = _Undefined,
_i1.CrdtDataRowVisibility? visibility,
_icw2tu00.CrdtDataRowVisibility? visibility,
Object? deleted = _Undefined,
Object? fields = _Undefined,
}) {
@ -301,97 +304,100 @@ class _CrdtDataRowImpl extends CrdtDataRow {
hlcDatetime: hlcDatetime ?? this.hlcDatetime,
hlcCounter: hlcCounter ?? this.hlcCounter,
scopeId: scopeId ?? this.scopeId,
scope: scope is _i1.CrdtScope? ? scope : this.scope?.copyWith(),
scope: scope is _icw2tu00.CrdtScope? ? scope : this.scope?.copyWith(),
tblId: tblId ?? this.tblId,
tbl: tbl is _i1.CrdtSchemaTable? ? tbl : this.tbl?.copyWith(),
tbl: tbl is _icw2tu00.CrdtSchemaTable? ? tbl : this.tbl?.copyWith(),
uuidRowId: uuidRowId ?? this.uuidRowId,
nodeId: nodeId ?? this.nodeId,
node: node is _i1.CrdtNode? ? node : this.node?.copyWith(),
node: node is _icw2tu00.CrdtNode? ? node : this.node?.copyWith(),
visibility: visibility ?? this.visibility,
deleted: deleted is _i1.CrdtDataDeleted?
deleted: deleted is _icw2tu00.CrdtDataDeleted?
? deleted
: this.deleted?.copyWith(),
fields: fields is List<_i1.CrdtDataField>?
fields: fields is List<_icw2tu00.CrdtDataField>?
? fields
: this.fields?.map((e0) => e0.copyWith()).toList(),
);
}
}
class CrdtDataRowUpdateTable extends _i2.UpdateTable<CrdtDataRowTable> {
class CrdtDataRowUpdateTable extends _isd.UpdateTable<CrdtDataRowTable> {
CrdtDataRowUpdateTable(super.table);
_i2.ColumnValue<DateTime, DateTime> hlcDatetime(DateTime value) =>
_i2.ColumnValue(
_isd.ColumnValue<DateTime, DateTime> hlcDatetime(DateTime value) =>
_isd.ColumnValue(
table.hlcDatetime,
value,
);
_i2.ColumnValue<int, int> hlcCounter(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> hlcCounter(int value) => _isd.ColumnValue(
table.hlcCounter,
value,
);
_i2.ColumnValue<int, int> scopeId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> scopeId(int value) => _isd.ColumnValue(
table.scopeId,
value,
);
_i2.ColumnValue<int, int> tblId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> tblId(int value) => _isd.ColumnValue(
table.tblId,
value,
);
_i2.ColumnValue<_i3.UuidValue, _i3.UuidValue> uuidRowId(
_i3.UuidValue value,
) => _i2.ColumnValue(
_isd.ColumnValue<_iss.UuidValue, _iss.UuidValue> uuidRowId(
_iss.UuidValue value,
) => _isd.ColumnValue(
table.uuidRowId,
value,
);
_i2.ColumnValue<int, int> nodeId(int value) => _i2.ColumnValue(
_isd.ColumnValue<int, int> nodeId(int value) => _isd.ColumnValue(
table.nodeId,
value,
);
_i2.ColumnValue<_i1.CrdtDataRowVisibility, _i1.CrdtDataRowVisibility>
visibility(_i1.CrdtDataRowVisibility value) => _i2.ColumnValue(
_isd.ColumnValue<
_icw2tu00.CrdtDataRowVisibility,
_icw2tu00.CrdtDataRowVisibility
>
visibility(_icw2tu00.CrdtDataRowVisibility value) => _isd.ColumnValue(
table.visibility,
value,
);
}
class CrdtDataRowTable extends _i2.Table<int?> {
class CrdtDataRowTable extends _isd.Table<int?> {
CrdtDataRowTable({super.tableRelation}) : super(tableName: 'crdt_data_rows') {
updateTable = CrdtDataRowUpdateTable(this);
hlcDatetime = _i2.ColumnDateTime(
hlcDatetime = _isd.ColumnDateTime(
'hlcDatetime',
this,
);
hlcCounter = _i2.ColumnInt(
hlcCounter = _isd.ColumnInt(
'hlcCounter',
this,
);
scopeId = _i2.ColumnInt(
scopeId = _isd.ColumnInt(
'scopeId',
this,
);
tblId = _i2.ColumnInt(
tblId = _isd.ColumnInt(
'tblId',
this,
);
uuidRowId = _i2.ColumnUuid(
uuidRowId = _isd.ColumnUuid(
'uuidRowId',
this,
);
nodeId = _i2.ColumnInt(
nodeId = _isd.ColumnInt(
'nodeId',
this,
);
visibility = _i2.ColumnEnum(
visibility = _isd.ColumnEnum(
'visibility',
this,
_i2.EnumSerialization.byIndex,
_isd.EnumSerialization.byIndex,
hasDefault: true,
);
}
@ -399,125 +405,125 @@ class CrdtDataRowTable extends _i2.Table<int?> {
late final CrdtDataRowUpdateTable updateTable;
/// The datetime component of the HLC timestamp.
late final _i2.ColumnDateTime hlcDatetime;
late final _isd.ColumnDateTime hlcDatetime;
/// The counter component of the HLC timestamp.
late final _i2.ColumnInt hlcCounter;
late final _isd.ColumnInt hlcCounter;
late final _i2.ColumnInt scopeId;
late final _isd.ColumnInt scopeId;
/// Identifier for the scope that owns the data.
_i1.CrdtScopeTable? _scope;
_icw2tu00.CrdtScopeTable? _scope;
late final _i2.ColumnInt tblId;
late final _isd.ColumnInt tblId;
/// Reference to the table this row belongs to.
_i1.CrdtSchemaTableTable? _tbl;
_icw2tu00.CrdtSchemaTableTable? _tbl;
/// Row identifier.
late final _i2.ColumnUuid uuidRowId;
late final _isd.ColumnUuid uuidRowId;
late final _i2.ColumnInt nodeId;
late final _isd.ColumnInt nodeId;
/// The node that inserted the row with the HLC timestamp.
_i1.CrdtNodeTable? _node;
_icw2tu00.CrdtNodeTable? _node;
/// Materialized visibility state for domain queries.
///
/// Updated by user tombstone writes and foreign key projection. Visible
/// states are listed before hidden states in CrdtDataRowVisibility.
late final _i2.ColumnEnum<_i1.CrdtDataRowVisibility> visibility;
late final _isd.ColumnEnum<_icw2tu00.CrdtDataRowVisibility> visibility;
/// The synced user tombstone for this row.
///
/// Only present after the first user visibility change event has been recorded.
/// Projection may keep a visible [visibility] while a user delete tombstone exists.
_i1.CrdtDataDeletedTable? _deleted;
_icw2tu00.CrdtDataDeletedTable? _deleted;
/// The fields for this row.
_i1.CrdtDataFieldTable? ___fields;
_icw2tu00.CrdtDataFieldTable? ___fields;
/// The fields for this row.
_i2.ManyRelation<_i1.CrdtDataFieldTable>? _fields;
_isd.ManyRelation<_icw2tu00.CrdtDataFieldTable>? _fields;
_i1.CrdtScopeTable get scope {
_icw2tu00.CrdtScopeTable get scope {
if (_scope != null) return _scope!;
_scope = _i2.createRelationTable(
_scope = _isd.createRelationTable(
relationFieldName: 'scope',
field: CrdtDataRow.t.scopeId,
foreignField: _i1.CrdtScope.t.id,
foreignField: _icw2tu00.CrdtScope.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtScopeTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtScopeTable(tableRelation: foreignTableRelation),
);
return _scope!;
}
_i1.CrdtSchemaTableTable get tbl {
_icw2tu00.CrdtSchemaTableTable get tbl {
if (_tbl != null) return _tbl!;
_tbl = _i2.createRelationTable(
_tbl = _isd.createRelationTable(
relationFieldName: 'tbl',
field: CrdtDataRow.t.tblId,
foreignField: _i1.CrdtSchemaTable.t.id,
foreignField: _icw2tu00.CrdtSchemaTable.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtSchemaTableTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtSchemaTableTable(tableRelation: foreignTableRelation),
);
return _tbl!;
}
_i1.CrdtNodeTable get node {
_icw2tu00.CrdtNodeTable get node {
if (_node != null) return _node!;
_node = _i2.createRelationTable(
_node = _isd.createRelationTable(
relationFieldName: 'node',
field: CrdtDataRow.t.nodeId,
foreignField: _i1.CrdtNode.t.id,
foreignField: _icw2tu00.CrdtNode.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtNodeTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtNodeTable(tableRelation: foreignTableRelation),
);
return _node!;
}
_i1.CrdtDataDeletedTable get deleted {
_icw2tu00.CrdtDataDeletedTable get deleted {
if (_deleted != null) return _deleted!;
_deleted = _i2.createRelationTable(
_deleted = _isd.createRelationTable(
relationFieldName: 'deleted',
field: CrdtDataRow.t.id,
foreignField: _i1.CrdtDataDeleted.t.rowId,
foreignField: _icw2tu00.CrdtDataDeleted.t.rowId,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtDataDeletedTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtDataDeletedTable(tableRelation: foreignTableRelation),
);
return _deleted!;
}
_i1.CrdtDataFieldTable get __fields {
_icw2tu00.CrdtDataFieldTable get __fields {
if (___fields != null) return ___fields!;
___fields = _i2.createRelationTable(
___fields = _isd.createRelationTable(
relationFieldName: '__fields',
field: CrdtDataRow.t.id,
foreignField: _i1.CrdtDataField.t.rowId,
foreignField: _icw2tu00.CrdtDataField.t.rowId,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtDataFieldTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtDataFieldTable(tableRelation: foreignTableRelation),
);
return ___fields!;
}
_i2.ManyRelation<_i1.CrdtDataFieldTable> get fields {
_isd.ManyRelation<_icw2tu00.CrdtDataFieldTable> get fields {
if (_fields != null) return _fields!;
var relationTable = _i2.createRelationTable(
var relationTable = _isd.createRelationTable(
relationFieldName: 'fields',
field: CrdtDataRow.t.id,
foreignField: _i1.CrdtDataField.t.rowId,
foreignField: _icw2tu00.CrdtDataField.t.rowId,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_i1.CrdtDataFieldTable(tableRelation: foreignTableRelation),
_icw2tu00.CrdtDataFieldTable(tableRelation: foreignTableRelation),
);
_fields = _i2.ManyRelation<_i1.CrdtDataFieldTable>(
_fields = _isd.ManyRelation<_icw2tu00.CrdtDataFieldTable>(
tableWithRelations: relationTable,
table: _i1.CrdtDataFieldTable(
table: _icw2tu00.CrdtDataFieldTable(
tableRelation: relationTable.tableRelation!.lastRelation,
),
);
@ -525,7 +531,7 @@ class CrdtDataRowTable extends _i2.Table<int?> {
}
@override
List<_i2.Column> get columns => [
List<_isd.Column> get columns => [
id,
hlcDatetime,
hlcCounter,
@ -537,7 +543,7 @@ class CrdtDataRowTable extends _i2.Table<int?> {
];
@override
_i2.Table? getRelationTable(String relationField) {
_isd.Table? getRelationTable(String relationField) {
if (relationField == 'scope') {
return scope;
}
@ -557,13 +563,13 @@ class CrdtDataRowTable extends _i2.Table<int?> {
}
}
class CrdtDataRowInclude extends _i2.IncludeObject {
class CrdtDataRowInclude extends _isd.IncludeObject {
CrdtDataRowInclude._({
_i1.CrdtScopeInclude? scope,
_i1.CrdtSchemaTableInclude? tbl,
_i1.CrdtNodeInclude? node,
_i1.CrdtDataDeletedInclude? deleted,
_i1.CrdtDataFieldIncludeList? fields,
_icw2tu00.CrdtScopeInclude? scope,
_icw2tu00.CrdtSchemaTableInclude? tbl,
_icw2tu00.CrdtNodeInclude? node,
_icw2tu00.CrdtDataDeletedInclude? deleted,
_icw2tu00.CrdtDataFieldIncludeList? fields,
}) {
_scope = scope;
_tbl = tbl;
@ -572,18 +578,18 @@ class CrdtDataRowInclude extends _i2.IncludeObject {
_fields = fields;
}
_i1.CrdtScopeInclude? _scope;
_icw2tu00.CrdtScopeInclude? _scope;
_i1.CrdtSchemaTableInclude? _tbl;
_icw2tu00.CrdtSchemaTableInclude? _tbl;
_i1.CrdtNodeInclude? _node;
_icw2tu00.CrdtNodeInclude? _node;
_i1.CrdtDataDeletedInclude? _deleted;
_icw2tu00.CrdtDataDeletedInclude? _deleted;
_i1.CrdtDataFieldIncludeList? _fields;
_icw2tu00.CrdtDataFieldIncludeList? _fields;
@override
Map<String, _i2.Include?> get includes => {
Map<String, _isd.Include?> get includes => {
'scope': _scope,
'tbl': _tbl,
'node': _node,
@ -592,12 +598,12 @@ class CrdtDataRowInclude extends _i2.IncludeObject {
};
@override
_i2.Table<int?> get table => CrdtDataRow.t;
_isd.Table<int?> get table => CrdtDataRow.t;
}
class CrdtDataRowIncludeList extends _i2.IncludeList {
class CrdtDataRowIncludeList extends _isd.IncludeList {
CrdtDataRowIncludeList._({
_i2.WhereExpressionBuilder<CrdtDataRowTable>? where,
_isd.WhereExpressionBuilder<CrdtDataRowTable>? where,
super.limit,
super.offset,
super.orderBy,
@ -608,10 +614,10 @@ class CrdtDataRowIncludeList extends _i2.IncludeList {
}
@override
Map<String, _i2.Include?> get includes => include?.includes ?? {};
Map<String, _isd.Include?> get includes => include?.includes ?? {};
@override
_i2.Table<int?> get table => CrdtDataRow.t;
_isd.Table<int?> get table => CrdtDataRow.t;
}
class CrdtDataRowRepository {
@ -644,16 +650,16 @@ class CrdtDataRowRepository {
/// );
/// ```
Future<List<CrdtDataRow>> find(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataRowTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataRowTable>? where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataRowTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataRowTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataRowInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.find<CrdtDataRow>(
where: where?.call(CrdtDataRow.t),
@ -686,15 +692,15 @@ class CrdtDataRowRepository {
/// );
/// ```
Future<CrdtDataRow?> findFirstRow(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataRowTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataRowTable>? where,
int? offset,
_i2.OrderByBuilder<CrdtDataRowTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataRowTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_isd.Transaction? transaction,
CrdtDataRowInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<CrdtDataRow>(
where: where?.call(CrdtDataRow.t),
@ -710,12 +716,12 @@ class CrdtDataRowRepository {
/// Finds a single [CrdtDataRow] by its [id] or null if no such row exists.
Future<CrdtDataRow?> findById(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
CrdtDataRowInclude? include,
_i2.LockMode? lockMode,
_i2.LockBehavior? lockBehavior,
_isd.LockMode? lockMode,
_isd.LockBehavior? lockBehavior,
}) async {
return session.db.findById<CrdtDataRow>(
id,
@ -741,9 +747,9 @@ class CrdtDataRowRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataRow>> insert(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataRow> rows, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
@ -759,9 +765,9 @@ class CrdtDataRowRepository {
///
/// The returned [CrdtDataRow] will have its `id` field set.
Future<CrdtDataRow> insertRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow row, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.insertRow<CrdtDataRow>(
row,
@ -790,12 +796,12 @@ class CrdtDataRowRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataRow>> upsert(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataRow> rows, {
required _i2.ColumnSelections<CrdtDataRowTable> conflictColumns,
_i2.ColumnSelections<CrdtDataRowTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataRowTable>? updateWhere,
_i2.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataRowTable> conflictColumns,
_isd.ColumnSelections<CrdtDataRowTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataRowTable>? updateWhere,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<CrdtDataRow>(
@ -822,12 +828,12 @@ class CrdtDataRowRepository {
///
/// The returned [CrdtDataRow] will have its `id` field set.
Future<CrdtDataRow?> upsertRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow row, {
required _i2.ColumnSelections<CrdtDataRowTable> conflictColumns,
_i2.ColumnSelections<CrdtDataRowTable>? updateColumns,
_i2.WhereExpressionBuilder<CrdtDataRowTable>? updateWhere,
_i2.Transaction? transaction,
required _isd.ColumnSelections<CrdtDataRowTable> conflictColumns,
_isd.ColumnSelections<CrdtDataRowTable>? updateColumns,
_isd.WhereExpressionBuilder<CrdtDataRowTable>? updateWhere,
_isd.Transaction? transaction,
}) async {
return session.db.upsertRow<CrdtDataRow>(
row,
@ -848,10 +854,10 @@ class CrdtDataRowRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataRow>> update(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataRow> rows, {
_i2.ColumnSelections<CrdtDataRowTable>? columns,
_i2.Transaction? transaction,
_isd.ColumnSelections<CrdtDataRowTable>? columns,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<CrdtDataRow>(
@ -866,10 +872,10 @@ class CrdtDataRowRepository {
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<CrdtDataRow> updateRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow row, {
_i2.ColumnSelections<CrdtDataRowTable>? columns,
_i2.Transaction? transaction,
_isd.ColumnSelections<CrdtDataRowTable>? columns,
_isd.Transaction? transaction,
}) async {
return session.db.updateRow<CrdtDataRow>(
row,
@ -881,10 +887,10 @@ class CrdtDataRowRepository {
/// Updates a single [CrdtDataRow] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<CrdtDataRow?> updateById(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
int id, {
required _i2.ColumnValueListBuilder<CrdtDataRowUpdateTable> columnValues,
_i2.Transaction? transaction,
required _isd.ColumnValueListBuilder<CrdtDataRowUpdateTable> columnValues,
_isd.Transaction? transaction,
}) async {
return session.db.updateById<CrdtDataRow>(
id,
@ -900,14 +906,14 @@ class CrdtDataRowRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataRow>> updateWhere(
_i2.DatabaseSession session, {
required _i2.ColumnValueListBuilder<CrdtDataRowUpdateTable> columnValues,
required _i2.WhereExpressionBuilder<CrdtDataRowTable> where,
_isd.DatabaseSession session, {
required _isd.ColumnValueListBuilder<CrdtDataRowUpdateTable> columnValues,
required _isd.WhereExpressionBuilder<CrdtDataRowTable> where,
int? limit,
int? offset,
_i2.OrderByBuilder<CrdtDataRowTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataRowTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<CrdtDataRow>(
@ -934,11 +940,11 @@ class CrdtDataRowRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataRow>> delete(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
List<CrdtDataRow> rows, {
_i2.OrderByBuilder<CrdtDataRowTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_i2.Transaction? transaction,
_isd.OrderByBuilder<CrdtDataRowTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<CrdtDataRow>(
@ -952,9 +958,9 @@ class CrdtDataRowRepository {
/// Deletes a single [CrdtDataRow].
Future<CrdtDataRow> deleteRow(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow row, {
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.deleteRow<CrdtDataRow>(
row,
@ -971,11 +977,11 @@ class CrdtDataRowRepository {
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<CrdtDataRow>> deleteWhere(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataRowTable> where,
_i2.OrderByBuilder<CrdtDataRowTable>? orderBy,
_i2.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_i2.Transaction? transaction,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataRowTable> where,
_isd.OrderByBuilder<CrdtDataRowTable>? orderBy,
_isd.OrderByListBuilder<CrdtDataRowTable>? orderByList,
_isd.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<CrdtDataRow>(
@ -990,10 +996,10 @@ class CrdtDataRowRepository {
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_i2.DatabaseSession session, {
_i2.WhereExpressionBuilder<CrdtDataRowTable>? where,
_isd.DatabaseSession session, {
_isd.WhereExpressionBuilder<CrdtDataRowTable>? where,
int? limit,
_i2.Transaction? transaction,
_isd.Transaction? transaction,
}) async {
return session.db.count<CrdtDataRow>(
where: where?.call(CrdtDataRow.t),
@ -1004,11 +1010,11 @@ class CrdtDataRowRepository {
/// Acquires row-level locks on [CrdtDataRow] rows matching the [where] expression.
Future<void> lockRows(
_i2.DatabaseSession session, {
required _i2.WhereExpressionBuilder<CrdtDataRowTable> where,
required _i2.LockMode lockMode,
required _i2.Transaction transaction,
_i2.LockBehavior lockBehavior = _i2.LockBehavior.wait,
_isd.DatabaseSession session, {
required _isd.WhereExpressionBuilder<CrdtDataRowTable> where,
required _isd.LockMode lockMode,
required _isd.Transaction transaction,
_isd.LockBehavior lockBehavior = _isd.LockBehavior.wait,
}) async {
return session.db.lockRows<CrdtDataRow>(
where: where(CrdtDataRow.t),
@ -1025,10 +1031,10 @@ class CrdtDataRowAttachRepository {
/// Creates a relation between this [CrdtDataRow] and the given [CrdtDataField]s
/// by setting each [CrdtDataField]'s foreign key `rowId` to refer to this [CrdtDataRow].
Future<void> fields(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow crdtDataRow,
List<_i1.CrdtDataField> crdtDataField, {
_i2.Transaction? transaction,
List<_icw2tu00.CrdtDataField> crdtDataField, {
_isd.Transaction? transaction,
}) async {
if (crdtDataField.any((e) => e.id == null)) {
throw ArgumentError.notNull('crdtDataField.id');
@ -1040,9 +1046,9 @@ class CrdtDataRowAttachRepository {
var $crdtDataField = crdtDataField
.map((e) => e.copyWith(rowId: crdtDataRow.id))
.toList();
await session.db.update<_i1.CrdtDataField>(
await session.db.update<_icw2tu00.CrdtDataField>(
$crdtDataField,
columns: [_i1.CrdtDataField.t.rowId],
columns: [_icw2tu00.CrdtDataField.t.rowId],
transaction: transaction,
);
}
@ -1054,10 +1060,10 @@ class CrdtDataRowAttachRowRepository {
/// Creates a relation between the given [CrdtDataRow] and [CrdtScope]
/// by setting the [CrdtDataRow]'s foreign key `scopeId` to refer to the [CrdtScope].
Future<void> scope(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow crdtDataRow,
_i1.CrdtScope scope, {
_i2.Transaction? transaction,
_icw2tu00.CrdtScope scope, {
_isd.Transaction? transaction,
}) async {
if (crdtDataRow.id == null) {
throw ArgumentError.notNull('crdtDataRow.id');
@ -1077,10 +1083,10 @@ class CrdtDataRowAttachRowRepository {
/// Creates a relation between the given [CrdtDataRow] and [CrdtSchemaTable]
/// by setting the [CrdtDataRow]'s foreign key `tblId` to refer to the [CrdtSchemaTable].
Future<void> tbl(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow crdtDataRow,
_i1.CrdtSchemaTable tbl, {
_i2.Transaction? transaction,
_icw2tu00.CrdtSchemaTable tbl, {
_isd.Transaction? transaction,
}) async {
if (crdtDataRow.id == null) {
throw ArgumentError.notNull('crdtDataRow.id');
@ -1100,10 +1106,10 @@ class CrdtDataRowAttachRowRepository {
/// Creates a relation between the given [CrdtDataRow] and [CrdtNode]
/// by setting the [CrdtDataRow]'s foreign key `nodeId` to refer to the [CrdtNode].
Future<void> node(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow crdtDataRow,
_i1.CrdtNode node, {
_i2.Transaction? transaction,
_icw2tu00.CrdtNode node, {
_isd.Transaction? transaction,
}) async {
if (crdtDataRow.id == null) {
throw ArgumentError.notNull('crdtDataRow.id');
@ -1123,10 +1129,10 @@ class CrdtDataRowAttachRowRepository {
/// Creates a relation between the given [CrdtDataRow] and [CrdtDataDeleted]
/// by setting the [CrdtDataRow]'s foreign key `id` to refer to the [CrdtDataDeleted].
Future<void> deleted(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow crdtDataRow,
_i1.CrdtDataDeleted deleted, {
_i2.Transaction? transaction,
_icw2tu00.CrdtDataDeleted deleted, {
_isd.Transaction? transaction,
}) async {
if (deleted.id == null) {
throw ArgumentError.notNull('deleted.id');
@ -1136,9 +1142,9 @@ class CrdtDataRowAttachRowRepository {
}
var $deleted = deleted.copyWith(rowId: crdtDataRow.id);
await session.db.updateRow<_i1.CrdtDataDeleted>(
await session.db.updateRow<_icw2tu00.CrdtDataDeleted>(
$deleted,
columns: [_i1.CrdtDataDeleted.t.rowId],
columns: [_icw2tu00.CrdtDataDeleted.t.rowId],
transaction: transaction,
);
}
@ -1146,10 +1152,10 @@ class CrdtDataRowAttachRowRepository {
/// Creates a relation between this [CrdtDataRow] and the given [CrdtDataField]
/// by setting the [CrdtDataField]'s foreign key `rowId` to refer to this [CrdtDataRow].
Future<void> fields(
_i2.DatabaseSession session,
_isd.DatabaseSession session,
CrdtDataRow crdtDataRow,
_i1.CrdtDataField crdtDataField, {
_i2.Transaction? transaction,
_icw2tu00.CrdtDataField crdtDataField, {
_isd.Transaction? transaction,
}) async {
if (crdtDataField.id == null) {
throw ArgumentError.notNull('crdtDataField.id');
@ -1159,9 +1165,9 @@ class CrdtDataRowAttachRowRepository {
}
var $crdtDataField = crdtDataField.copyWith(rowId: crdtDataRow.id);
await session.db.updateRow<_i1.CrdtDataField>(
await session.db.updateRow<_icw2tu00.CrdtDataField>(
$crdtDataField,
columns: [_i1.CrdtDataField.t.rowId],
columns: [_icw2tu00.CrdtDataField.t.rowId],
transaction: transaction,
);
}

View file

@ -10,13 +10,13 @@
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i1;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// Materialized visibility state for a CRDT row.
///
/// Visible states are listed first, hidden states last. A row is visible when
/// its serialized index is less than or equal to [foreignKeyRestrictRestore].
enum CrdtDataRowVisibility implements _i1.SerializableModel {
enum CrdtDataRowVisibility implements _iss.SerializableModel {
userInsert,
userReinsert,
foreignKeyRestrictRestore,

View file

@ -10,13 +10,13 @@
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i1;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
/// Base class for HLC timestamps.
///
/// This class is used to represent the base HLC timestamp, which will be
/// extended with the node ID (in its canonical or normalized form).
class BaseHlc implements _i1.SerializableModel, _i1.ProtocolSerialization {
class BaseHlc implements _iss.SerializableModel, _iss.ProtocolSerialization {
BaseHlc({
required this.hlcDatetime,
required this.hlcCounter,
@ -24,7 +24,7 @@ class BaseHlc implements _i1.SerializableModel, _i1.ProtocolSerialization {
factory BaseHlc.fromJson(Map<String, dynamic> jsonSerialization) {
return BaseHlc(
hlcDatetime: _i1.DateTimeJsonExtension.fromJson(
hlcDatetime: _iss.DateTimeJsonExtension.fromJson(
jsonSerialization['hlcDatetime'],
),
hlcCounter: jsonSerialization['hlcCounter'] as int,
@ -39,7 +39,7 @@ class BaseHlc implements _i1.SerializableModel, _i1.ProtocolSerialization {
/// Returns a shallow copy of this [BaseHlc]
/// with some or all fields replaced by the given arguments.
@_i1.useResult
@_iss.useResult
BaseHlc copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
@ -70,6 +70,6 @@ class BaseHlc implements _i1.SerializableModel, _i1.ProtocolSerialization {
@override
String toString() {
return _i1.SerializationManager.encode(this);
return _iss.SerializationManager.encode(this);
}
}

View file

@ -10,15 +10,16 @@
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i1;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _i2;
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
as _icw2tu00;
import 'package:serverpod_serialization/serverpod_serialization.dart' as _iss;
part 'delete.dart';
part 'insert.dart';
part 'update.dart';
/// A remote CRDT change to merge.
sealed class CrdtMergeChange extends _i1.BaseHlc
implements _i2.SerializableModel, _i2.ProtocolSerialization {
sealed class CrdtMergeChange extends _icw2tu00.BaseHlc
implements _iss.SerializableModel, _iss.ProtocolSerialization {
CrdtMergeChange({
required super.hlcDatetime,
required super.hlcCounter,
@ -29,27 +30,27 @@ sealed class CrdtMergeChange extends _i1.BaseHlc
});
/// The scope this change belongs to.
_i2.UuidValue uuidScopeId;
_iss.UuidValue uuidScopeId;
/// The table receiving the change.
String tableName;
/// The domain row identifier receiving the change.
_i2.UuidValue uuidRowId;
_iss.UuidValue uuidRowId;
/// The remote node that produced the change.
_i2.UuidValue uuidNodeId;
_iss.UuidValue uuidNodeId;
/// Returns a shallow copy of this [CrdtMergeChange]
/// with some or all fields replaced by the given arguments.
@_i2.useResult
@_iss.useResult
CrdtMergeChange copyWith({
DateTime? hlcDatetime,
int? hlcCounter,
_i2.UuidValue? uuidScopeId,
_iss.UuidValue? uuidScopeId,
String? tableName,
_i2.UuidValue? uuidRowId,
_i2.UuidValue? uuidNodeId,
_iss.UuidValue? uuidRowId,
_iss.UuidValue? uuidNodeId,
});
}

Some files were not shown because too many files have changed in this diff Show more