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,50 +10,52 @@
|
|||
// ignore_for_file: invalid_use_of_internal_member
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod/serverpod.dart' as _i1;
|
||||
import '../endpoints/crdt_sync_endpoint.dart' as _i2;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i3;
|
||||
import 'package:serverpod/serverpod.dart' as _is;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
|
||||
as _icw2tu00;
|
||||
import '../endpoints/crdt_sync_endpoint.dart' as _i87mlr2k;
|
||||
|
||||
class Endpoints extends _i1.EndpointDispatch {
|
||||
class Endpoints extends _is.EndpointDispatch {
|
||||
@override
|
||||
void initializeEndpoints(_i1.Server server) {
|
||||
var endpoints = <String, _i1.Endpoint>{
|
||||
'crdtSync': _i2.CrdtSyncEndpoint()
|
||||
void initializeEndpoints(_is.Server server) {
|
||||
var endpoints = <String, _is.Endpoint>{
|
||||
'crdtSync': _i87mlr2k.CrdtSyncEndpoint()
|
||||
..initialize(
|
||||
server,
|
||||
'crdtSync',
|
||||
'serverpod_offline_sync',
|
||||
),
|
||||
};
|
||||
connectors['crdtSync'] = _i1.EndpointConnector(
|
||||
connectors['crdtSync'] = _is.EndpointConnector(
|
||||
name: 'crdtSync',
|
||||
endpoint: endpoints['crdtSync']!,
|
||||
methodConnectors: {
|
||||
'sync': _i1.MethodStreamConnector(
|
||||
'sync': _is.MethodStreamConnector(
|
||||
name: 'sync',
|
||||
params: {
|
||||
'once': _i1.ParameterDescription(
|
||||
'once': _is.ParameterDescription(
|
||||
name: 'once',
|
||||
type: _i1.getType<bool>(),
|
||||
type: _is.getType<bool>(),
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
streamParams: {
|
||||
'changes': _i1.StreamParameterDescription<_i3.CrdtSyncStreamEvent>(
|
||||
name: 'changes',
|
||||
nullable: false,
|
||||
),
|
||||
'changes':
|
||||
_is.StreamParameterDescription<_icw2tu00.CrdtSyncStreamEvent>(
|
||||
name: 'changes',
|
||||
nullable: false,
|
||||
),
|
||||
},
|
||||
returnType: _i1.MethodStreamReturnType.streamType,
|
||||
returnType: _is.MethodStreamReturnType.streamType,
|
||||
call:
|
||||
(
|
||||
_i1.Session session,
|
||||
_is.Session session,
|
||||
Map<String, dynamic> params,
|
||||
Map<String, Stream> streamParams,
|
||||
) => (endpoints['crdtSync'] as _i2.CrdtSyncEndpoint).sync(
|
||||
) => (endpoints['crdtSync'] as _i87mlr2k.CrdtSyncEndpoint).sync(
|
||||
session,
|
||||
changes: streamParams['changes']!
|
||||
.cast<_i3.CrdtSyncStreamEvent>(),
|
||||
.cast<_icw2tu00.CrdtSyncStreamEvent>(),
|
||||
once: params['once'],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -11,34 +11,35 @@
|
|||
// ignore_for_file: dead_code, unnecessary_type_check
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:serverpod/serverpod.dart' as _i1;
|
||||
import 'package:serverpod/protocol.dart' as _i2;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart' as _i3;
|
||||
import 'package:serverpod/protocol.dart' as _isp;
|
||||
import 'package:serverpod/serverpod.dart' as _is;
|
||||
import 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
|
||||
as _icw2tu00;
|
||||
export 'package:serverpod_offline_sync/serverpod_offline_sync.dart'
|
||||
hide Protocol;
|
||||
|
||||
class Protocol extends _i1.DatabaseSerializationManager {
|
||||
class Protocol extends _is.DatabaseSerializationManager {
|
||||
Protocol._();
|
||||
|
||||
factory Protocol() => _instance;
|
||||
|
||||
static final Protocol _instance = Protocol._();
|
||||
|
||||
final Set<_i1.SerializationManager> _hostProtocols = {};
|
||||
final Set<_is.SerializationManager> _hostProtocols = {};
|
||||
|
||||
static List<_i2.TableDefinition> get targetTableDefinitions => [
|
||||
..._i3.Protocol() is _i1.DatabaseSerializationManager
|
||||
? (_i3.Protocol() as _i1.DatabaseSerializationManager)
|
||||
static List<_isp.TableDefinition> get targetTableDefinitions => [
|
||||
..._icw2tu00.Protocol() is _is.DatabaseSerializationManager
|
||||
? (_icw2tu00.Protocol() as _is.DatabaseSerializationManager)
|
||||
.getTargetTableDefinitions()
|
||||
: [],
|
||||
];
|
||||
|
||||
void registerHostProtocol(
|
||||
String projectName,
|
||||
_i1.SerializationManager protocol,
|
||||
_is.SerializationManager protocol,
|
||||
) {
|
||||
_hostProtocols.add(protocol);
|
||||
_i3.Protocol().registerHostProtocol(projectName, protocol);
|
||||
_icw2tu00.Protocol().registerHostProtocol(projectName, protocol);
|
||||
}
|
||||
|
||||
static String? getClassNameFromObjectJson(dynamic data) {
|
||||
|
|
@ -70,24 +71,24 @@ 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 == _i1.getType<_i3.Hlc?>()) {
|
||||
return (data != null ? _i3.Hlc.fromJson(data) : null) as T;
|
||||
if (t == _is.getType<_icw2tu00.Hlc?>()) {
|
||||
return (data != null ? _icw2tu00.Hlc.fromJson(data) : null) as T;
|
||||
}
|
||||
try {
|
||||
return _i3.Protocol().deserialize<T>(data, t);
|
||||
} on _i1.DeserializationTypeNotFoundException catch (_) {}
|
||||
return _icw2tu00.Protocol().deserialize<T>(data, t);
|
||||
} on _is.DeserializationTypeNotFoundException catch (_) {}
|
||||
try {
|
||||
return _i2.Protocol().deserialize<T>(data, t);
|
||||
} on _i1.DeserializationTypeNotFoundException catch (_) {}
|
||||
return _isp.Protocol().deserialize<T>(data, t);
|
||||
} on _is.DeserializationTypeNotFoundException catch (_) {}
|
||||
return super.deserialize<T>(data, t);
|
||||
}
|
||||
|
||||
static String? getClassNameForType(Type type) {
|
||||
return switch (type) {
|
||||
_i3.Hlc => 'Hlc',
|
||||
_icw2tu00.Hlc => 'Hlc',
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
|
@ -105,12 +106,12 @@ 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;
|
||||
className = _i2.Protocol().getClassNameForObject(data);
|
||||
className = _isp.Protocol().getClassNameForObject(data);
|
||||
if (className != null) {
|
||||
return className.contains('.') ? className : 'serverpod.$className';
|
||||
}
|
||||
|
|
@ -124,14 +125,14 @@ 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 (_) {}
|
||||
if (dataClassName.startsWith('serverpod.')) {
|
||||
data['className'] = dataClassName.substring(10);
|
||||
return _i2.Protocol().deserializeByClassName(data);
|
||||
return _isp.Protocol().deserializeByClassName(data);
|
||||
}
|
||||
return super.deserializeByClassName(data);
|
||||
}
|
||||
|
|
@ -154,8 +155,8 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
'data': object,
|
||||
};
|
||||
return forProtocol
|
||||
? _i1.SerializationManager.toEncodableForProtocol(wrapped)
|
||||
: _i1.SerializationManager.toEncodable(wrapped);
|
||||
? _is.SerializationManager.toEncodableForProtocol(wrapped)
|
||||
: _is.SerializationManager.toEncodable(wrapped);
|
||||
}
|
||||
return super.dynamicFieldToJson(object, forProtocol: forProtocol);
|
||||
}
|
||||
|
|
@ -196,18 +197,18 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
}
|
||||
|
||||
@override
|
||||
_i1.Table? getTableForType(Type t) {
|
||||
_is.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 _is.DatabaseSerializationManager
|
||||
? (protocol as _is.DatabaseSerializationManager).getTableForType(t)
|
||||
: null;
|
||||
if (table != null) {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
{
|
||||
var table = _i2.Protocol().getTableForType(t);
|
||||
var table = _isp.Protocol().getTableForType(t);
|
||||
if (table != null) {
|
||||
return table;
|
||||
}
|
||||
|
|
@ -216,7 +217,7 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
}
|
||||
|
||||
@override
|
||||
List<_i2.TableDefinition> getTargetTableDefinitions() =>
|
||||
List<_isp.TableDefinition> getTargetTableDefinitions() =>
|
||||
targetTableDefinitions;
|
||||
|
||||
@override
|
||||
|
|
@ -232,7 +233,7 @@ class Protocol extends _i1.DatabaseSerializationManager {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
return _i2.Protocol().mapRecordToJson(record);
|
||||
return _isp.Protocol().mapRecordToJson(record);
|
||||
} catch (_) {}
|
||||
throw Exception('Unsupported record type ${record.runtimeType}');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue