Skip to content

Commit

Permalink
chore(sdk): Reduce library namespace sizes
Browse files Browse the repository at this point in the history
In the SDK packages, reduce the amount of work the analyzer has to do by judiciously importing and exporting the required files in libraries.

Regenerates SDK examples based on these changes.
  • Loading branch information
dnys1 committed Sep 29, 2024
1 parent d75c809 commit cf55b38
Show file tree
Hide file tree
Showing 27 changed files with 944 additions and 149 deletions.
9 changes: 5 additions & 4 deletions packages/celest/example/celest/client/lib/example_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'dart:io' as _$io;
import 'package:celest_core/_internal.dart' as _$celest;
import 'package:celest_core/src/util/globals.dart' as _$celest;
import 'package:http/http.dart' as _$http;
import 'package:native_storage/native_storage.dart' as _$native_storage;

import 'src/functions.dart';
import 'src/serializers.dart';
Expand All @@ -24,8 +25,8 @@ enum CelestEnvironment {

Uri get baseUri => switch (this) {
local => _$celest.kIsWeb || !_$io.Platform.isAndroid
? Uri.parse('http://localhost:52792')
: Uri.parse('http://10.0.2.2:52792'),
? Uri.parse('http://localhost:52794')
: Uri.parse('http://10.0.2.2:52794'),
};
}

Expand All @@ -34,8 +35,8 @@ class Celest with _$celest.CelestBase {

late CelestEnvironment _currentEnvironment;

late final _$celest.NativeStorage nativeStorage =
_$celest.NativeStorage(scope: 'celest');
late final _$native_storage.NativeStorage nativeStorage =
_$native_storage.NativeStorage(scope: 'celest');

@override
late _$http.Client httpClient =
Expand Down
57 changes: 57 additions & 0 deletions packages/celest/example/celest/client/lib/src/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import 'package:celest/celest.dart' as _$celest;
import 'package:celest_backend/exceptions/bad_name_exception.dart';
import 'package:celest_backend/models/person.dart';
import 'package:celest_core/celest_core.dart' as _$celest;
import 'package:celest_core/src/exception/cloud_exception.dart' as _$celest;
import 'package:celest_core/src/exception/serialization_exception.dart'
as _$celest;

import '../example_client.dart';

Expand All @@ -27,6 +30,60 @@ class CelestFunctionsGreeting {
final $message = ($error['message'] as String?);
final $details = ($error['details'] as _$celest.JsonMap?);
switch ($code) {
case r'celest.core.v1.CloudException':
throw _$celest.Serializers.instance
.deserialize<_$celest.CloudException>($details);
case r'celest.core.v1.CancelledException':
throw _$celest.Serializers.instance
.deserialize<_$celest.CancelledException>($details);
case r'celest.core.v1.UnknownError':
throw _$celest.Serializers.instance
.deserialize<_$celest.UnknownError>($details);
case r'celest.core.v1.BadRequestException':
throw _$celest.Serializers.instance
.deserialize<_$celest.BadRequestException>($details);
case r'celest.core.v1.UnauthorizedException':
throw _$celest.Serializers.instance
.deserialize<_$celest.UnauthorizedException>($details);
case r'celest.core.v1.NotFoundException':
throw _$celest.Serializers.instance
.deserialize<_$celest.NotFoundException>($details);
case r'celest.core.v1.AlreadyExistsException':
throw _$celest.Serializers.instance
.deserialize<_$celest.AlreadyExistsException>($details);
case r'celest.core.v1.PermissionDeniedException':
throw _$celest.Serializers.instance
.deserialize<_$celest.PermissionDeniedException>($details);
case r'celest.core.v1.ResourceExhaustedException':
throw _$celest.Serializers.instance
.deserialize<_$celest.ResourceExhaustedException>($details);
case r'celest.core.v1.FailedPreconditionException':
throw _$celest.Serializers.instance
.deserialize<_$celest.FailedPreconditionException>($details);
case r'celest.core.v1.AbortedException':
throw _$celest.Serializers.instance
.deserialize<_$celest.AbortedException>($details);
case r'celest.core.v1.OutOfRangeException':
throw _$celest.Serializers.instance
.deserialize<_$celest.OutOfRangeException>($details);
case r'celest.core.v1.UnimplementedError':
throw _$celest.Serializers.instance
.deserialize<_$celest.UnimplementedError>($details);
case r'celest.core.v1.InternalServerError':
throw _$celest.Serializers.instance
.deserialize<_$celest.InternalServerError>($details);
case r'celest.core.v1.UnavailableError':
throw _$celest.Serializers.instance
.deserialize<_$celest.UnavailableError>($details);
case r'celest.core.v1.DataLossError':
throw _$celest.Serializers.instance
.deserialize<_$celest.DataLossError>($details);
case r'celest.core.v1.DeadlineExceededError':
throw _$celest.Serializers.instance
.deserialize<_$celest.DeadlineExceededError>($details);
case r'celest.core.v1.SerializationException':
throw _$celest.Serializers.instance
.deserialize<_$celest.SerializationException>($details);
case r'example.v1.BadNameException':
throw _$celest.Serializers.instance
.deserialize<BadNameException>($details);
Expand Down
Loading

0 comments on commit cf55b38

Please sign in to comment.