chore: Update to Serverpod 4.0.0-beta.4 (#112)
This commit is contained in:
parent
c04bde5e6f
commit
852c81c64a
2 changed files with 29163 additions and 10676 deletions
|
|
@ -10,26 +10,27 @@
|
|||
// ignore_for_file: invalid_use_of_internal_member
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod_client/serverpod_client.dart' as _i1;
|
||||
import 'dart:async' as _i2;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i3;
|
||||
import 'dart:async' as _ida;
|
||||
import 'package:serverpod_client/serverpod_client.dart' as _isc;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
|
||||
as _icw2tu00;
|
||||
|
||||
/// Endpoint for CRDT-based offline-first synchronization.
|
||||
/// {@category Endpoint}
|
||||
class EndpointCrdtSync extends _i1.EndpointRef {
|
||||
EndpointCrdtSync(_i1.EndpointCaller caller) : super(caller);
|
||||
class EndpointCrdtSync extends _isc.EndpointRef {
|
||||
EndpointCrdtSync(_isc.EndpointCaller caller) : super(caller);
|
||||
|
||||
@override
|
||||
String get name => 'serverpod_offline_sync.crdtSync';
|
||||
|
||||
/// Opens a bidirectional CRDT sync session with the authenticated client.
|
||||
_i2.Stream<_i3.CrdtSyncStreamEvent> sync({
|
||||
required _i2.Stream<_i3.CrdtSyncStreamEvent> changes,
|
||||
_ida.Stream<_icw2tu00.CrdtSyncStreamEvent> sync({
|
||||
required _ida.Stream<_icw2tu00.CrdtSyncStreamEvent> changes,
|
||||
required bool once,
|
||||
}) =>
|
||||
caller.callStreamingServerEndpoint<
|
||||
_i2.Stream<_i3.CrdtSyncStreamEvent>,
|
||||
_i3.CrdtSyncStreamEvent
|
||||
_ida.Stream<_icw2tu00.CrdtSyncStreamEvent>,
|
||||
_icw2tu00.CrdtSyncStreamEvent
|
||||
>(
|
||||
'serverpod_offline_sync.crdtSync',
|
||||
'sync',
|
||||
|
|
@ -38,15 +39,15 @@ class EndpointCrdtSync extends _i1.EndpointRef {
|
|||
);
|
||||
}
|
||||
|
||||
class Caller extends _i1.ModuleEndpointCaller {
|
||||
Caller(_i1.ServerpodClientShared client) : super(client) {
|
||||
class Caller extends _isc.ModuleEndpointCaller {
|
||||
Caller(_isc.ServerpodClientShared client) : super(client) {
|
||||
crdtSync = EndpointCrdtSync(this);
|
||||
}
|
||||
|
||||
late final EndpointCrdtSync crdtSync;
|
||||
|
||||
@override
|
||||
Map<String, _i1.EndpointRef> get endpointRefLookup => {
|
||||
Map<String, _isc.EndpointRef> get endpointRefLookup => {
|
||||
'serverpod_offline_sync.crdtSync': crdtSync,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,35 +11,36 @@
|
|||
// ignore_for_file: dead_code, unnecessary_type_check
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod_database/serverpod_database.dart' as _i1;
|
||||
import 'package:serverpod_client/serverpod_client.dart' as _i2;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i3;
|
||||
import 'package:serverpod_client/serverpod_client.dart' as _isc;
|
||||
import 'package:serverpod_database/serverpod_database.dart' as _isd;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
|
||||
as _icw2tu00;
|
||||
export 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
|
||||
hide Protocol;
|
||||
export 'client.dart';
|
||||
|
||||
class Protocol extends _i1.DatabaseSerializationManager {
|
||||
class Protocol extends _isd.DatabaseSerializationManager {
|
||||
Protocol._();
|
||||
|
||||
factory Protocol() => _instance;
|
||||
|
||||
static final Protocol _instance = Protocol._();
|
||||
|
||||
final Set<_i2.SerializationManager> _hostProtocols = {};
|
||||
final Set<_isc.SerializationManager> _hostProtocols = {};
|
||||
|
||||
static List<_i1.TableDefinition> get targetTableDefinitions => [
|
||||
..._i3.Protocol() is _i1.DatabaseSerializationManager
|
||||
? (_i3.Protocol() as _i1.DatabaseSerializationManager)
|
||||
static List<_isd.TableDefinition> get targetTableDefinitions => [
|
||||
..._icw2tu00.Protocol() is _isd.DatabaseSerializationManager
|
||||
? (_icw2tu00.Protocol() as _isd.DatabaseSerializationManager)
|
||||
.getTargetTableDefinitions()
|
||||
: [],
|
||||
];
|
||||
|
||||
void registerHostProtocol(
|
||||
String projectName,
|
||||
_i2.SerializationManager protocol,
|
||||
_isc.SerializationManager protocol,
|
||||
) {
|
||||
_hostProtocols.add(protocol);
|
||||
_i3.Protocol().registerHostProtocol(projectName, protocol);
|
||||
_icw2tu00.Protocol().registerHostProtocol(projectName, protocol);
|
||||
}
|
||||
|
||||
static String? getClassNameFromObjectJson(dynamic data) {
|
||||
|
|
@ -71,21 +72,21 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
}
|
||||
}
|
||||
|
||||
if (t == _i3.Hlc) {
|
||||
return _i3.Hlc.fromJson(data) as T;
|
||||
if (t == _icw2tu00.Hlc) {
|
||||
return _icw2tu00.Hlc.fromJson(data) as T;
|
||||
}
|
||||
if (t == _i2.getType<_i3.Hlc?>()) {
|
||||
return (data != null ? _i3.Hlc.fromJson(data) : null) as T;
|
||||
if (t == _isc.getType<_icw2tu00.Hlc?>()) {
|
||||
return (data != null ? _icw2tu00.Hlc.fromJson(data) : null) as T;
|
||||
}
|
||||
try {
|
||||
return _i3.Protocol().deserialize<T>(data, t);
|
||||
} on _i2.DeserializationTypeNotFoundException catch (_) {}
|
||||
return _icw2tu00.Protocol().deserialize<T>(data, t);
|
||||
} on _isc.DeserializationTypeNotFoundException catch (_) {}
|
||||
return super.deserialize<T>(data, t);
|
||||
}
|
||||
|
||||
static String? getClassNameForType(Type type) {
|
||||
return switch (type) {
|
||||
_i3.Hlc => 'Hlc',
|
||||
_icw2tu00.Hlc => 'Hlc',
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
|
@ -103,10 +104,10 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
}
|
||||
|
||||
switch (data) {
|
||||
case _i3.Hlc():
|
||||
case _icw2tu00.Hlc():
|
||||
return 'Hlc';
|
||||
}
|
||||
className = _i3.Protocol().getClassNameForObject(data);
|
||||
className = _icw2tu00.Protocol().getClassNameForObject(data);
|
||||
if (className != null) return className;
|
||||
return null;
|
||||
}
|
||||
|
|
@ -118,10 +119,10 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
return super.deserializeByClassName(data);
|
||||
}
|
||||
if (dataClassName == 'Hlc') {
|
||||
return deserialize<_i3.Hlc>(data['data']);
|
||||
return deserialize<_icw2tu00.Hlc>(data['data']);
|
||||
}
|
||||
try {
|
||||
return _i3.Protocol().deserializeByClassName(data);
|
||||
return _icw2tu00.Protocol().deserializeByClassName(data);
|
||||
} on FormatException catch (_) {}
|
||||
return super.deserializeByClassName(data);
|
||||
}
|
||||
|
|
@ -144,8 +145,8 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
'data': object,
|
||||
};
|
||||
return forProtocol
|
||||
? _i2.SerializationManager.toEncodableForProtocol(wrapped)
|
||||
: _i2.SerializationManager.toEncodable(wrapped);
|
||||
? _isc.SerializationManager.toEncodableForProtocol(wrapped)
|
||||
: _isc.SerializationManager.toEncodable(wrapped);
|
||||
}
|
||||
return super.dynamicFieldToJson(object, forProtocol: forProtocol);
|
||||
}
|
||||
|
|
@ -186,11 +187,11 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
}
|
||||
|
||||
@override
|
||||
_i1.Table? getTableForType(Type t) {
|
||||
_isd.Table? getTableForType(Type t) {
|
||||
{
|
||||
var protocol = _i3.Protocol();
|
||||
var table = protocol is _i1.DatabaseSerializationManager
|
||||
? (protocol as _i1.DatabaseSerializationManager).getTableForType(t)
|
||||
var protocol = _icw2tu00.Protocol();
|
||||
var table = protocol is _isd.DatabaseSerializationManager
|
||||
? (protocol as _isd.DatabaseSerializationManager).getTableForType(t)
|
||||
: null;
|
||||
if (table != null) {
|
||||
return table;
|
||||
|
|
@ -200,7 +201,7 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
}
|
||||
|
||||
@override
|
||||
List<_i1.TableDefinition> getTargetTableDefinitions() =>
|
||||
List<_isd.TableDefinition> getTargetTableDefinitions() =>
|
||||
targetTableDefinitions;
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Reference in a new issue