Skip to content

Commit 88f0777

Browse files
committed
Generate code
1 parent dbbf9fe commit 88f0777

30 files changed

Lines changed: 3365 additions & 4545 deletions

File tree

modules/new_serverpod_auth/serverpod_auth_backwards_compatibility/serverpod_auth_backwards_compatibility_client/lib/src/protocol/client.dart

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,37 @@
1010

1111
// ignore_for_file: no_leading_underscores_for_library_prefixes
1212
import 'package:serverpod_client/serverpod_client.dart' as _i1;
13+
import 'dart:async' as _i2;
14+
import 'package:serverpod_auth_session_client/serverpod_auth_session_client.dart'
15+
as _i3;
16+
17+
/// Enpoint to convert legacy sessions.
18+
/// {@category Endpoint}
19+
class EndpointSessionMigration extends _i1.EndpointRef {
20+
EndpointSessionMigration(_i1.EndpointCaller caller) : super(caller);
21+
22+
@override
23+
String get name => 'serverpod_auth_backwards_compatibility.sessionMigration';
24+
25+
/// Converts a legacy session into a `serverpod_auth_session` one.
26+
_i2.Future<_i3.AuthSuccess?> convertSession({required String sessionKey}) =>
27+
caller.callServerEndpoint<_i3.AuthSuccess?>(
28+
'serverpod_auth_backwards_compatibility.sessionMigration',
29+
'convertSession',
30+
{'sessionKey': sessionKey},
31+
);
32+
}
1333

1434
class Caller extends _i1.ModuleEndpointCaller {
15-
Caller(_i1.ServerpodClientShared client) : super(client) {}
35+
Caller(_i1.ServerpodClientShared client) : super(client) {
36+
sessionMigration = EndpointSessionMigration(this);
37+
}
38+
39+
late final EndpointSessionMigration sessionMigration;
1640

1741
@override
18-
Map<String, _i1.EndpointRef> get endpointRefLookup => {};
42+
Map<String, _i1.EndpointRef> get endpointRefLookup => {
43+
'serverpod_auth_backwards_compatibility.sessionMigration':
44+
sessionMigration
45+
};
1946
}

modules/new_serverpod_auth/serverpod_auth_backwards_compatibility/serverpod_auth_backwards_compatibility_client/lib/src/protocol/protocol.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
import 'package:serverpod_client/serverpod_client.dart' as _i1;
1313
import 'package:serverpod_auth_email_account_client/serverpod_auth_email_account_client.dart'
1414
as _i2;
15-
import 'package:serverpod_auth_user_client/serverpod_auth_user_client.dart'
15+
import 'package:serverpod_auth_session_client/serverpod_auth_session_client.dart'
1616
as _i3;
17+
import 'package:serverpod_auth_user_client/serverpod_auth_user_client.dart'
18+
as _i4;
1719
export 'client.dart';
1820

1921
class Protocol extends _i1.SerializationManager {
@@ -35,6 +37,9 @@ class Protocol extends _i1.SerializationManager {
3537
try {
3638
return _i3.Protocol().deserialize<T>(data, t);
3739
} on _i1.DeserializationTypeNotFoundException catch (_) {}
40+
try {
41+
return _i4.Protocol().deserialize<T>(data, t);
42+
} on _i1.DeserializationTypeNotFoundException catch (_) {}
3843
return super.deserialize<T>(data, t);
3944
}
4045

@@ -47,6 +52,10 @@ class Protocol extends _i1.SerializationManager {
4752
return 'serverpod_auth_email_account.$className';
4853
}
4954
className = _i3.Protocol().getClassNameForObject(data);
55+
if (className != null) {
56+
return 'serverpod_auth_session.$className';
57+
}
58+
className = _i4.Protocol().getClassNameForObject(data);
5059
if (className != null) {
5160
return 'serverpod_auth_user.$className';
5261
}
@@ -63,9 +72,13 @@ class Protocol extends _i1.SerializationManager {
6372
data['className'] = dataClassName.substring(29);
6473
return _i2.Protocol().deserializeByClassName(data);
6574
}
75+
if (dataClassName.startsWith('serverpod_auth_session.')) {
76+
data['className'] = dataClassName.substring(23);
77+
return _i3.Protocol().deserializeByClassName(data);
78+
}
6679
if (dataClassName.startsWith('serverpod_auth_user.')) {
6780
data['className'] = dataClassName.substring(20);
68-
return _i3.Protocol().deserializeByClassName(data);
81+
return _i4.Protocol().deserializeByClassName(data);
6982
}
7083
return super.deserializeByClassName(data);
7184
}

modules/new_serverpod_auth/serverpod_auth_backwards_compatibility/serverpod_auth_backwards_compatibility_server/lib/src/generated/endpoints.dart

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,55 @@
1010

1111
// ignore_for_file: no_leading_underscores_for_library_prefixes
1212
import 'package:serverpod/serverpod.dart' as _i1;
13+
import '../endpoints/session_migration_endpoint.dart' as _i2;
1314
import 'package:serverpod_auth_email_account_server/serverpod_auth_email_account_server.dart'
14-
as _i2;
15-
import 'package:serverpod_auth_user_server/serverpod_auth_user_server.dart'
1615
as _i3;
16+
import 'package:serverpod_auth_session_server/serverpod_auth_session_server.dart'
17+
as _i4;
18+
import 'package:serverpod_auth_user_server/serverpod_auth_user_server.dart'
19+
as _i5;
1720

1821
class Endpoints extends _i1.EndpointDispatch {
1922
@override
2023
void initializeEndpoints(_i1.Server server) {
21-
modules['serverpod_auth_email_account'] = _i2.Endpoints()
24+
var endpoints = <String, _i1.Endpoint>{
25+
'sessionMigration': _i2.SessionMigrationEndpoint()
26+
..initialize(
27+
server,
28+
'sessionMigration',
29+
'serverpod_auth_backwards_compatibility',
30+
)
31+
};
32+
connectors['sessionMigration'] = _i1.EndpointConnector(
33+
name: 'sessionMigration',
34+
endpoint: endpoints['sessionMigration']!,
35+
methodConnectors: {
36+
'convertSession': _i1.MethodConnector(
37+
name: 'convertSession',
38+
params: {
39+
'sessionKey': _i1.ParameterDescription(
40+
name: 'sessionKey',
41+
type: _i1.getType<String>(),
42+
nullable: false,
43+
)
44+
},
45+
call: (
46+
_i1.Session session,
47+
Map<String, dynamic> params,
48+
) async =>
49+
(endpoints['sessionMigration'] as _i2.SessionMigrationEndpoint)
50+
.convertSession(
51+
session,
52+
sessionKey: params['sessionKey'],
53+
),
54+
)
55+
},
56+
);
57+
modules['serverpod_auth_email_account'] = _i3.Endpoints()
58+
..initializeEndpoints(server);
59+
modules['serverpod_auth_session'] = _i4.Endpoints()
2260
..initializeEndpoints(server);
23-
modules['serverpod_auth_user'] = _i3.Endpoints()
61+
modules['serverpod_auth_user'] = _i5.Endpoints()
2462
..initializeEndpoints(server);
2563
}
2664
}

modules/new_serverpod_auth/serverpod_auth_backwards_compatibility/serverpod_auth_backwards_compatibility_server/lib/src/generated/legacy_session.dart

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ abstract class LegacySession
2222
required this.authUserId,
2323
this.authUser,
2424
required this.scopeNames,
25-
this.lastUsed,
2625
required this.hash,
2726
required this.method,
2827
});
@@ -32,7 +31,6 @@ abstract class LegacySession
3231
required _i1.UuidValue authUserId,
3332
_i2.AuthUser? authUser,
3433
required Set<String> scopeNames,
35-
DateTime? lastUsed,
3634
required String hash,
3735
required String method,
3836
}) = _LegacySessionImpl;
@@ -49,9 +47,6 @@ abstract class LegacySession
4947
scopeNames: _i1.SetJsonExtension.fromJson(
5048
(jsonSerialization['scopeNames'] as List),
5149
itemFromJson: (e) => e as String)!,
52-
lastUsed: jsonSerialization['lastUsed'] == null
53-
? null
54-
: _i1.DateTimeJsonExtension.fromJson(jsonSerialization['lastUsed']),
5550
hash: jsonSerialization['hash'] as String,
5651
method: jsonSerialization['method'] as String,
5752
);
@@ -72,13 +67,6 @@ abstract class LegacySession
7267
/// The scopes this session provides access to.
7368
Set<String> scopeNames;
7469

75-
/// The time when this access session was last used by a client.
76-
///
77-
/// Operates only with minute resolution, to avoid excessive writes to the database.
78-
///
79-
/// Unused sessions will have a value of `null`.
80-
DateTime? lastUsed;
81-
8270
/// The hashed version of the key (as the legacy `AuthKey`)
8371
String hash;
8472

@@ -98,7 +86,6 @@ abstract class LegacySession
9886
_i1.UuidValue? authUserId,
9987
_i2.AuthUser? authUser,
10088
Set<String>? scopeNames,
101-
DateTime? lastUsed,
10289
String? hash,
10390
String? method,
10491
});
@@ -109,7 +96,6 @@ abstract class LegacySession
10996
'authUserId': authUserId.toJson(),
11097
if (authUser != null) 'authUser': authUser?.toJson(),
11198
'scopeNames': scopeNames.toJson(),
112-
if (lastUsed != null) 'lastUsed': lastUsed?.toJson(),
11399
'hash': hash,
114100
'method': method,
115101
};
@@ -158,15 +144,13 @@ class _LegacySessionImpl extends LegacySession {
158144
required _i1.UuidValue authUserId,
159145
_i2.AuthUser? authUser,
160146
required Set<String> scopeNames,
161-
DateTime? lastUsed,
162147
required String hash,
163148
required String method,
164149
}) : super._(
165150
id: id,
166151
authUserId: authUserId,
167152
authUser: authUser,
168153
scopeNames: scopeNames,
169-
lastUsed: lastUsed,
170154
hash: hash,
171155
method: method,
172156
);
@@ -180,7 +164,6 @@ class _LegacySessionImpl extends LegacySession {
180164
_i1.UuidValue? authUserId,
181165
Object? authUser = _Undefined,
182166
Set<String>? scopeNames,
183-
Object? lastUsed = _Undefined,
184167
String? hash,
185168
String? method,
186169
}) {
@@ -190,7 +173,6 @@ class _LegacySessionImpl extends LegacySession {
190173
authUser:
191174
authUser is _i2.AuthUser? ? authUser : this.authUser?.copyWith(),
192175
scopeNames: scopeNames ?? this.scopeNames.map((e0) => e0).toSet(),
193-
lastUsed: lastUsed is DateTime? ? lastUsed : this.lastUsed,
194176
hash: hash ?? this.hash,
195177
method: method ?? this.method,
196178
);
@@ -208,10 +190,6 @@ class LegacySessionTable extends _i1.Table<int?> {
208190
'scopeNames',
209191
this,
210192
);
211-
lastUsed = _i1.ColumnDateTime(
212-
'lastUsed',
213-
this,
214-
);
215193
hash = _i1.ColumnString(
216194
'hash',
217195
this,
@@ -230,13 +208,6 @@ class LegacySessionTable extends _i1.Table<int?> {
230208
/// The scopes this session provides access to.
231209
late final _i1.ColumnSerializable scopeNames;
232210

233-
/// The time when this access session was last used by a client.
234-
///
235-
/// Operates only with minute resolution, to avoid excessive writes to the database.
236-
///
237-
/// Unused sessions will have a value of `null`.
238-
late final _i1.ColumnDateTime lastUsed;
239-
240211
/// The hashed version of the key (as the legacy `AuthKey`)
241212
late final _i1.ColumnString hash;
242213

@@ -263,7 +234,6 @@ class LegacySessionTable extends _i1.Table<int?> {
263234
id,
264235
authUserId,
265236
scopeNames,
266-
lastUsed,
267237
hash,
268238
method,
269239
];

0 commit comments

Comments
 (0)