/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */ /* To generate run: "serverpod generate" */ // ignore_for_file: implementation_imports // ignore_for_file: library_private_types_in_public_api // ignore_for_file: non_constant_identifier_names // ignore_for_file: public_member_api_docs // ignore_for_file: type_literal_in_constant_pattern // ignore_for_file: use_super_parameters // ignore_for_file: invalid_use_of_internal_member // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _ida; import 'package:halkyon_learn_client/src/protocol/auth/device.dart' as _ieqh4yr9; import 'package:halkyon_learn_client/src/protocol/instance/instance_info.dart' as _i26u8vl4; import 'package:http/http.dart' as _i85jenna; import 'package:serverpod_auth_core_client/serverpod_auth_core_client.dart' as _iacc; import 'package:serverpod_auth_idp_client/serverpod_auth_idp_client.dart' as _iaic; import 'package:serverpod_client/serverpod_client.dart' as _isc; import 'package:serverpod_database/serverpod_database.dart' as _isd; import 'package:serverpod_offline_sync_client/serverpod_offline_sync_client.dart' as _ipulbpi2; import 'protocol.dart' as _il2as5qe; import 'sync_tables.dart' as _ii3f3u05; import 'package:halkyon_learn_client/migrations/migration_registry.dart'; /// Signs people in anonymously; the app calls it on first launch. Creating an /// account is rate-limited per IP address (see `auth_config.dart`). /// {@category Endpoint} class EndpointAnonymousIdp extends _iaic.EndpointAnonymousIdpBase { EndpointAnonymousIdp(_isc.EndpointCaller caller) : super(caller); @override String get name => 'anonymousIdp'; /// Creates a new anonymous account and returns its session. /// /// Invokes the [AnonymousIdp.beforeAnonymousAccount] callback if configured, /// which may prevent account creation if the endpoint is protected. @override _ida.Future<_iacc.AuthSuccess> login({String? token}) => caller.callServerEndpoint<_iacc.AuthSuccess>( 'anonymousIdp', 'login', {'token': token}, ); } /// Your devices: the sessions you're signed in with, and signing one of them /// out, for example a lost phone. /// /// Serverpod has no row-level security, so this endpoint enforces access /// itself, like every endpoint: the person always comes from the session, /// never from the client; every query filters by them; and someone else's /// device answers exactly like a missing one. /// {@category Endpoint} class EndpointDevices extends _isc.EndpointRef { EndpointDevices(_isc.EndpointCaller caller) : super(caller); @override String get name => 'devices'; /// Your devices, the most recently used first. _ida.Future> list() => caller.callServerEndpoint>( 'devices', 'list', {}, ); /// Signs out one of your devices. Throws [NotFoundException] when it isn't /// yours, exactly as when it doesn't exist. _ida.Future signOut(_isc.UuidValue sessionId) => caller.callServerEndpoint( 'devices', 'signOut', {'sessionId': sessionId}, ); } /// Signs in the person who already has a GitHub account, e.g. when they switch /// to it on another device. Called without a session: Serverpod issues no /// session for another person inside a signed-in call. /// {@category Endpoint} class EndpointGitHubSignIn extends _isc.EndpointRef { EndpointGitHubSignIn(_isc.EndpointCaller caller) : super(caller); @override String get name => 'gitHubSignIn'; /// A session for the person with the GitHub account that [code] proves; /// refusals as in [signInWithGitHubAccount]. _ida.Future<_iacc.AuthSuccess> signIn({ required String code, required String codeVerifier, required String redirectUri, }) => caller.callServerEndpoint<_iacc.AuthSuccess>( 'gitHubSignIn', 'signIn', { 'code': code, 'codeVerifier': codeVerifier, 'redirectUri': redirectUri, }, ); } /// Links a GitHub account to the signed-in person: the lossless upgrade from /// an anonymous account. The person, their spaces and their studysets stay /// where they are; only the way they sign in changes. /// {@category Endpoint} class EndpointGitHubUpgrade extends _isc.EndpointRef { EndpointGitHubUpgrade(_isc.EndpointCaller caller) : super(caller); @override String get name => 'gitHubUpgrade'; /// Links the GitHub account that [code] proves to the caller; refusals as in /// [linkGitHubAccount]. _ida.Future upgrade({ required String code, required String codeVerifier, required String redirectUri, }) => caller.callServerEndpoint( 'gitHubUpgrade', 'upgrade', { 'code': code, 'codeVerifier': codeVerifier, 'redirectUri': redirectUri, }, ); } /// What this instance offers. Public: the app asks before anyone is signed in. /// {@category Endpoint} class EndpointInstance extends _isc.EndpointRef { EndpointInstance(_isc.EndpointCaller caller) : super(caller); @override String get name => 'instance'; /// This instance's offer: GitHub sign-in only with the operator's OAuth /// app, and where its source is. _ida.Future<_i26u8vl4.InstanceInfo> info() => caller.callServerEndpoint<_i26u8vl4.InstanceInfo>( 'instance', 'info', {}, ); } class Modules { Modules(Client client) { serverpod_auth_idp = _iaic.Caller(client); offline_sync = _ipulbpi2.Caller(client); serverpod_auth_core = _iacc.Caller(client); } late final _iaic.Caller serverpod_auth_idp; late final _ipulbpi2.Caller offline_sync; late final _iacc.Caller serverpod_auth_core; } class Client extends _isc.ServerpodClientShared { Client( String host, { dynamic securityContext, Duration? streamingConnectionTimeout, Duration? connectionTimeout, Function( _isc.MethodCallContext, Object, StackTrace, )? onFailedCall, Function(_isc.MethodCallContext)? onSucceededCall, bool? disconnectStreamsOnLostInternetConnection, _i85jenna.Client? httpClientOverride, }) : super( host, _il2as5qe.Protocol(), securityContext: securityContext, streamingConnectionTimeout: streamingConnectionTimeout, connectionTimeout: connectionTimeout, onFailedCall: onFailedCall, onSucceededCall: onSucceededCall, disconnectStreamsOnLostInternetConnection: disconnectStreamsOnLostInternetConnection, httpClientOverride: httpClientOverride, ) { anonymousIdp = EndpointAnonymousIdp(this); devices = EndpointDevices(this); gitHubSignIn = EndpointGitHubSignIn(this); gitHubUpgrade = EndpointGitHubUpgrade(this); instance = EndpointInstance(this); modules = Modules(this); } late final EndpointAnonymousIdp anonymousIdp; late final EndpointDevices devices; late final EndpointGitHubSignIn gitHubSignIn; late final EndpointGitHubUpgrade gitHubUpgrade; late final EndpointInstance instance; late final Modules modules; @override Map get endpointRefLookup => { 'anonymousIdp': anonymousIdp, 'devices': devices, 'gitHubSignIn': gitHubSignIn, 'gitHubUpgrade': gitHubUpgrade, 'instance': instance, }; @override Map get moduleLookup => { 'serverpod_auth_idp': modules.serverpod_auth_idp, 'offline_sync': modules.offline_sync, 'serverpod_auth_core': modules.serverpod_auth_core, }; /// Creates a new client-side database session for the given path. /// /// The [path] is the file path to the SQLite database file. Since SQLite uses /// WAL mode, note that `[path]-shm` and `[path]-wal` files might also exist /// transiently for the database while the session is open. /// /// If [runMigrations] is true, pending migrations will be applied when /// opening the database. Be careful when setting this to false, as it might /// lead to inconsistencies between the models and the database. /// /// If [isDebugMode] is true, the database integrity will be verified after /// the migrations are applied to provide feedback of possible issues. On a /// Flutter application, this should be set to [kDebugMode]. _ida.Future<_isd.ClientDatabaseSession> createSession( String path, { bool runMigrations = true, bool isDebugMode = false, }) async { return await _isd.ClientDatabaseSession.open( path, _il2as5qe.Protocol(), clientMigrations: MigrationRegistry.migrations, runMigrations: runMigrations, isDebugMode: isDebugMode, ); } /// Creates a new client-side database session for the given path, wrapped /// with the `serverpod_offline_sync` engine for the tables declared with /// `database: sync`. See [createSession] for the [path], [runMigrations] and /// [isDebugMode] parameters. /// /// The [persistentUserId] is the user all local operations belong to. When /// omitted, the user must be passed through the transaction. _ida.Future<_ipulbpi2.OfflineSyncDatabaseSession> createSyncSession( String path, { bool runMigrations = true, bool isDebugMode = false, _isc.UuidValue? persistentUserId, }) async { final session = _ipulbpi2.OfflineSyncDatabaseSession.wraps( await createSession( path, runMigrations: runMigrations, isDebugMode: isDebugMode, ), syncTables: _ii3f3u05.syncTables, persistentUserId: persistentUserId, ); await session.db.initialize(); return session; } }