Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/celest_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046 # 2.19.0
with:
channel: stable
channel: beta
cache: true
- name: Get Packages
working-directory: packages/celest_auth
Expand All @@ -42,7 +42,7 @@ jobs:
run: dart analyze --fatal-infos --fatal-warnings
- name: Format
working-directory: packages/celest_auth
run: dart format --set-exit-if-changed .
run: dart format --language-version=latest --set-exit-if-changed .
# - name: Test
# working-directory: packages/celest_auth
# run: dart test
Expand Down
5 changes: 5 additions & 0 deletions packages/celest_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## NEXT

- chore: Re-format with Dart 3.8
- chore: Update linter/style preferences

## 1.0.2

- chore: Make close part of the public API (#267)
Expand Down
2 changes: 1 addition & 1 deletion packages/celest_auth/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:flutter_lints/flutter.yaml
include: package:celest_lints/app.yaml

analyzer:
plugins:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ enum CelestEnvironment {
local;

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

class Celest with _$celest.CelestBase {
Expand All @@ -41,22 +42,21 @@ class Celest with _$celest.CelestBase {
_$native_storage_native_storage.NativeStorage(scope: 'celest');

@override
late _$http_http.Client httpClient =
_$celest.CelestHttpClient(secureStorage: nativeStorage.secure);
late _$http_http.Client httpClient = _$celest.CelestHttpClient(
secureStorage: nativeStorage.secure,
);

late Uri _baseUri;

final _functions = CelestFunctions();

late CelestAuth _auth = CelestAuth(
this,
storage: nativeStorage,
);
late CelestAuth _auth = CelestAuth(this, storage: nativeStorage);

T _checkInitialized<T>(T Function() value) {
if (!_initialized) {
throw StateError(
'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.');
'Celest has not been initialized. Make sure to call `celest.init()` at the start of your `main` method.',
);
}
return value();
}
Expand Down Expand Up @@ -87,10 +87,7 @@ class Celest with _$celest.CelestBase {

void _reset() {
_auth.close().ignore();
_auth = CelestAuth(
this,
storage: nativeStorage,
);
_auth = CelestAuth(this, storage: nativeStorage);
_initialized = false;
}
}
5 changes: 1 addition & 4 deletions packages/celest_auth/example/celest/client/lib/src/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ extension type CelestAuth._(_$celest.AuthImpl _hub) implements _$celest.Auth {
CelestAuth(
_$celest.CelestBase celest, {
required _$native_storage_native_storage.NativeStorage storage,
}) : _hub = _$celest.AuthImpl(
celest,
storage: storage,
);
}) : _hub = _$celest.AuthImpl(celest, storage: storage);

_$celest.Email get email => _$celest.Email(_hub);
}
87 changes: 47 additions & 40 deletions packages/celest_auth/example/celest/client/lib/src/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ class CelestFunctions {
}

class CelestFunctionsGreeting {
Never _throwError({
int? code,
required Map<String, Object?> body,
}) {
Never _throwError({int? code, required Map<String, Object?> body}) {
final status = body['@status'] as Map<String, Object?>?;
final message = status?['message'] as String?;
final details = status?['details'] as _$celest.JsonList?;
Expand All @@ -32,27 +29,28 @@ class CelestFunctionsGreeting {
final errorDetails as Map<String, Object?>,
{
'@type': 'dart.core.StackTrace',
'value': final stackTraceValue as String
'value': final stackTraceValue as String,
},
...
...,
] =>
(
errorDetails['@type'],
errorDetails['value'],
StackTrace.fromString(stackTraceValue),
),
[final errorDetails as Map<String, Object?>, ...] => (
errorDetails['@type'],
errorDetails['value'],
StackTrace.empty,
),
errorDetails['@type'],
errorDetails['value'],
StackTrace.empty,
),
};

switch (errorType) {
case 'celest.core.v1.CloudException':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<_$celest.CloudException>(errorValue),
_$celest.Serializers.instance.deserialize<_$celest.CloudException>(
errorValue,
),
stackTrace,
);
case 'celest.core.v1.CancelledException':
Expand All @@ -63,8 +61,9 @@ class CelestFunctionsGreeting {
);
case 'celest.core.v1.UnknownError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<_$celest.UnknownError>(errorValue),
_$celest.Serializers.instance.deserialize<_$celest.UnknownError>(
errorValue,
),
stackTrace,
);
case 'celest.core.v1.BadRequestException':
Expand All @@ -81,8 +80,9 @@ class CelestFunctionsGreeting {
);
case 'celest.core.v1.NotFoundException':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<_$celest.NotFoundException>(errorValue),
_$celest.Serializers.instance.deserialize<_$celest.NotFoundException>(
errorValue,
),
stackTrace,
);
case 'celest.core.v1.AlreadyExistsException':
Expand Down Expand Up @@ -111,8 +111,9 @@ class CelestFunctionsGreeting {
);
case 'celest.core.v1.AbortedException':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<_$celest.AbortedException>(errorValue),
_$celest.Serializers.instance.deserialize<_$celest.AbortedException>(
errorValue,
),
stackTrace,
);
case 'celest.core.v1.OutOfRangeException':
Expand All @@ -135,14 +136,16 @@ class CelestFunctionsGreeting {
);
case 'celest.core.v1.UnavailableError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<_$celest.UnavailableError>(errorValue),
_$celest.Serializers.instance.deserialize<_$celest.UnavailableError>(
errorValue,
),
stackTrace,
);
case 'celest.core.v1.DataLossError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<_$celest.DataLossError>(errorValue),
_$celest.Serializers.instance.deserialize<_$celest.DataLossError>(
errorValue,
),
stackTrace,
);
case 'celest.core.v1.DeadlineExceededError':
Expand Down Expand Up @@ -189,14 +192,16 @@ class CelestFunctionsGreeting {
);
case 'dart.core.UnsupportedError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<UnsupportedError>(errorValue),
_$celest.Serializers.instance.deserialize<UnsupportedError>(
errorValue,
),
stackTrace,
);
case 'dart.core.UnimplementedError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<UnimplementedError>(errorValue),
_$celest.Serializers.instance.deserialize<UnimplementedError>(
errorValue,
),
stackTrace,
);
case 'dart.core.StateError':
Expand All @@ -212,14 +217,16 @@ class CelestFunctionsGreeting {
);
case 'dart.core.OutOfMemoryError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<OutOfMemoryError>(errorValue),
_$celest.Serializers.instance.deserialize<OutOfMemoryError>(
errorValue,
),
stackTrace,
);
case 'dart.core.StackOverflowError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<StackOverflowError>(errorValue),
_$celest.Serializers.instance.deserialize<StackOverflowError>(
errorValue,
),
stackTrace,
);
case 'dart.core.Exception':
Expand All @@ -229,8 +236,9 @@ class CelestFunctionsGreeting {
);
case 'dart.core.FormatException':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<FormatException>(errorValue),
_$celest.Serializers.instance.deserialize<FormatException>(
errorValue,
),
stackTrace,
);
case 'dart.core.IntegerDivisionByZeroException':
Expand All @@ -246,14 +254,16 @@ class CelestFunctionsGreeting {
);
case 'dart.async.TimeoutException':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<TimeoutException>(errorValue),
_$celest.Serializers.instance.deserialize<TimeoutException>(
errorValue,
),
stackTrace,
);
case 'dart.convert.JsonUnsupportedObjectError':
Error.throwWithStackTrace(
_$celest.Serializers.instance
.deserialize<JsonUnsupportedObjectError>(errorValue),
_$celest.Serializers.instance.deserialize<JsonUnsupportedObjectError>(
errorValue,
),
stackTrace,
);
default:
Expand All @@ -269,10 +279,7 @@ class CelestFunctionsGreeting {
}

/// Says hello to the authenticated [user].
@_$celest.CloudFunction(
api: 'greeting',
function: 'sayHello',
)
@_$celest.CloudFunction(api: 'greeting', function: 'sayHello')
Future<String> sayHello() async {
final $response = await celest.httpClient.post(
celest.baseUri.resolve('/greeting/say-hello'),
Expand Down
Loading