From b34cce148bdb545e8cf08839ce0e86da8b27817c Mon Sep 17 00:00:00 2001 From: Dillon Nys Date: Wed, 9 Oct 2024 21:05:57 -0700 Subject: [PATCH] chore(repo): Update examples Regenerate example projects using latest CLI changes. --- .../client/lib/gemini_example_client.dart | 4 +- .../celest/client/lib/src/functions.dart | 410 +++++--- .../celest/client/lib/src/serializers.dart | 44 +- examples/gemini/celest/client/pubspec.yaml | 19 +- .../lib/src/generated/cloud.celest.dart | 12 +- .../lib/src/generated/config.celest.dart | 4 +- examples/gemini/celest/pubspec.yaml | 13 +- .../client/lib/openai_example_client.dart | 4 +- .../celest/client/lib/src/functions.dart | 362 +++++-- .../celest/client/lib/src/serializers.dart | 44 +- examples/openai/celest/client/pubspec.yaml | 19 +- .../lib/src/generated/cloud.celest.dart | 12 +- .../lib/src/generated/config.celest.dart | 4 +- examples/openai/celest/pubspec.yaml | 13 +- .../celest/client/lib/example_client.dart | 19 +- .../celest/client/lib/src/functions.dart | 335 ++++-- .../celest/client/lib/src/serializers.dart | 991 ++++++++++++------ .../celest/example/celest/client/pubspec.yaml | 11 +- .../lib/src/generated/cloud.celest.dart | 42 + .../lib/src/generated/config.celest.dart | 53 + .../celest/lib/src/generated/resources.dart | 5 - .../example/celest/lib/src/project.dart | 5 + packages/celest/example/celest/project.dart | 6 +- packages/celest/example/celest/pubspec.yaml | 7 +- .../lib/celest_auth_example_client.dart | 22 +- .../example/celest/client/lib/src/auth.dart | 2 +- .../celest/client/lib/src/functions.dart | 324 ++++-- .../celest/client/lib/src/serializers.dart | 963 +++++++++++------ .../example/celest/client/pubspec.yaml | 20 +- .../lib/src/generated/cloud.celest.dart | 42 + .../lib/src/generated/config.celest.dart | 53 + .../celest/lib/src/generated/resources.dart | 5 - .../example/celest/lib/src/project.dart | 12 + .../celest_auth/example/celest/project.dart | 13 +- .../celest_auth/example/celest/pubspec.yaml | 14 +- 35 files changed, 2718 insertions(+), 1190 deletions(-) create mode 100644 packages/celest/example/celest/lib/src/generated/cloud.celest.dart create mode 100644 packages/celest/example/celest/lib/src/generated/config.celest.dart delete mode 100644 packages/celest/example/celest/lib/src/generated/resources.dart create mode 100644 packages/celest/example/celest/lib/src/project.dart mode change 100644 => 120000 packages/celest/example/celest/project.dart create mode 100644 packages/celest_auth/example/celest/lib/src/generated/cloud.celest.dart create mode 100644 packages/celest_auth/example/celest/lib/src/generated/config.celest.dart delete mode 100644 packages/celest_auth/example/celest/lib/src/generated/resources.dart create mode 100644 packages/celest_auth/example/celest/lib/src/project.dart mode change 100644 => 120000 packages/celest_auth/example/celest/project.dart diff --git a/examples/gemini/celest/client/lib/gemini_example_client.dart b/examples/gemini/celest/client/lib/gemini_example_client.dart index 4b30309c..21d97ec0 100644 --- a/examples/gemini/celest/client/lib/gemini_example_client.dart +++ b/examples/gemini/celest/client/lib/gemini_example_client.dart @@ -21,8 +21,8 @@ enum CelestEnvironment { Uri get baseUri => switch (this) { local => _$celest.kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:7786') - : Uri.parse('http://10.0.2.2:7786'), + ? Uri.parse('http://localhost:7787') + : Uri.parse('http://10.0.2.2:7787'), }; } diff --git a/examples/gemini/celest/client/lib/src/functions.dart b/examples/gemini/celest/client/lib/src/functions.dart index cc52b8f0..66c7e2d7 100644 --- a/examples/gemini/celest/client/lib/src/functions.dart +++ b/examples/gemini/celest/client/lib/src/functions.dart @@ -22,137 +22,276 @@ class CelestFunctions { class CelestFunctionsGemini { Never _throwError({ - required int? $statusCode, - required Map $body, + int? code, + required Map body, }) { - final $error = ($body['@error'] as Map?); - $statusCode ??= ($error?['status'] as num?)?.toInt(); - final $code = ($error?['code'] as String); - final $message = ($body['message'] as String?); - final $details = ($body['@'] as _$celest.JsonValue?) ?? - ($body['details'] as _$celest.JsonMap?); - switch ($code) { - case r'dart.convert.JsonUnsupportedObjectError': - throw _$celest.Serializers.instance - .deserialize<_$convert.JsonUnsupportedObjectError>($details); - case r'dart.async.AsyncError': - throw _$celest.Serializers.instance - .deserialize<_$async.AsyncError>($details); - case r'dart.async.TimeoutException': - throw _$celest.Serializers.instance - .deserialize<_$async.TimeoutException>($details); - case r'dart.core.Error': - throw _$celest.Serializers.instance.deserialize($details); - case r'dart.core.AssertionError': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.TypeError': - throw _$celest.Serializers.instance.deserialize($details); - case r'dart.core.ArgumentError': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.RangeError': - throw _$celest.Serializers.instance.deserialize($details); - case r'dart.core.IndexError': - throw _$celest.Serializers.instance.deserialize($details); - case r'dart.core.UnsupportedError': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.UnimplementedError': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.StateError': - throw _$celest.Serializers.instance.deserialize($details); - case r'dart.core.ConcurrentModificationError': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.OutOfMemoryError': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.StackOverflowError': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.FormatException': - throw _$celest.Serializers.instance - .deserialize($details); - case r'dart.core.IntegerDivisionByZeroException': - throw _$celest.Serializers.instance - .deserialize($details); - 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'google_generative_ai.GenerativeAIException': - throw _$celest.Serializers.instance - .deserialize<_$error.GenerativeAIException>($details); - case r'google_generative_ai.InvalidApiKey': - throw _$celest.Serializers.instance - .deserialize<_$error.InvalidApiKey>($details); - case r'google_generative_ai.UnsupportedUserLocation': - throw _$celest.Serializers.instance - .deserialize<_$error.UnsupportedUserLocation>($details); - case r'google_generative_ai.ServerException': - throw _$celest.Serializers.instance - .deserialize<_$error.ServerException>($details); - case r'http.ClientException': - throw _$celest.Serializers.instance - .deserialize<_$exception.ClientException>($details); + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String + }, + ... + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$convert.JsonUnsupportedObjectError>(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.AsyncError>(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.TimeoutException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CloudException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnknownError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.NotFoundException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AbortedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnavailableError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DataLossError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'google_generative_ai.GenerativeAIException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$error.GenerativeAIException>(errorValue), + stackTrace, + ); + case 'google_generative_ai.InvalidApiKey': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$error.InvalidApiKey>(errorValue), + stackTrace, + ); + case 'google_generative_ai.UnsupportedUserLocation': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$error.UnsupportedUserLocation>(errorValue), + stackTrace, + ); + case 'google_generative_ai.ServerException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$error.ServerException>(errorValue), + stackTrace, + ); + case 'http.ClientException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$exception.ClientException>(errorValue), + stackTrace, + ); default: - throw _$celest.CloudException.http( - status: $statusCode, - code: $code, - message: $message, - details: $details, + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, ); } } @@ -165,13 +304,16 @@ class CelestFunctionsGemini { Future> availableModels() async { final $response = await celest.httpClient.post( celest.baseUri.resolve('/gemini/available-models'), - headers: {'Content-Type': 'application/json; charset=utf-8'}, + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, ); - final $body = _$convert.jsonDecode($response.body); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); if ($response.statusCode != 200) { _throwError( - $statusCode: $response.statusCode, - $body: $body, + code: $response.statusCode, + body: ($body as Map), ); } return ($body as Iterable).map((el) => (el as String)).toList(); @@ -196,7 +338,7 @@ class CelestFunctionsGemini { }); return $channel.stream.map(($event) { if ($event is Map && $event.containsKey('@error')) { - _throwError($statusCode: -1, $body: $event); + _throwError(body: $event); } return ($event as String); }); diff --git a/examples/gemini/celest/client/lib/src/serializers.dart b/examples/gemini/celest/client/lib/src/serializers.dart index aaeecd71..b57d777b 100644 --- a/examples/gemini/celest/client/lib/src/serializers.dart +++ b/examples/gemini/celest/client/lib/src/serializers.dart @@ -217,6 +217,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.AbortedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -228,6 +229,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.AbortedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -239,6 +241,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.AlreadyExistsException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -250,6 +253,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.AlreadyExistsException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -261,6 +265,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.BadRequestException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -272,6 +277,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.BadRequestException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -283,6 +289,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.CancelledException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -294,6 +301,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.CancelledException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -305,6 +313,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.CloudException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -320,6 +329,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.DataLossError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -331,6 +341,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.DataLossError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -342,6 +353,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.DeadlineExceededError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -353,6 +365,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.DeadlineExceededError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -364,6 +377,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.FailedPreconditionException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -375,6 +389,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.FailedPreconditionException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -386,6 +401,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.InternalServerError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -397,6 +413,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.InternalServerError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -408,6 +425,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.NotFoundException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -419,6 +437,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.NotFoundException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -430,6 +449,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.OutOfRangeException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -441,6 +461,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.OutOfRangeException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -452,6 +473,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.PermissionDeniedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -463,6 +485,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.PermissionDeniedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -474,6 +497,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.ResourceExhaustedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -485,6 +509,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.ResourceExhaustedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -496,6 +521,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.UnauthorizedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -507,6 +533,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.UnauthorizedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -518,6 +545,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.UnavailableError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -529,6 +557,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.UnavailableError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -538,8 +567,9 @@ void initSerializers({_$celest.Serializers? serializers}) { }, )); _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnimplementedError, Map?>( + _$celest.UnimplementedError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -550,12 +580,20 @@ void initSerializers({_$celest.Serializers? serializers}) { }, deserialize: ($serialized) { return _$celest.UnimplementedError( - ($serialized?[r'message'] as String?)); + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); }, )); _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.UnknownError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -567,6 +605,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.UnknownError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -578,6 +617,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.SerializationException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, diff --git a/examples/gemini/celest/client/pubspec.yaml b/examples/gemini/celest/client/pubspec.yaml index aaf2a285..6548f180 100644 --- a/examples/gemini/celest/client/pubspec.yaml +++ b/examples/gemini/celest/client/pubspec.yaml @@ -6,21 +6,26 @@ environment: sdk: ^3.4.0 dependencies: + celest: ^1.0.0-0 celest_backend: path: .. - celest: '^1.0.0-0' - celest_core: '^1.0.0-0' - meta: '^1.12.0' - native_storage: '^0.2.2' + celest_core: ^1.0.0-0 + http: ^1.0.0 + meta: ^1.12.0 + native_storage: ^0.2.2 -dev_dependencies: {} +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 dependency_overrides: celest: path: ../../../../packages/celest - celest_core: - path: ../../../../packages/celest_core + celest_ast: + path: ../../../../packages/celest_ast celest_auth: path: ../../../../packages/celest_auth celest_cloud: path: ../../../../packages/celest_cloud + celest_core: + path: ../../../../packages/celest_core diff --git a/examples/gemini/celest/lib/src/generated/cloud.celest.dart b/examples/gemini/celest/lib/src/generated/cloud.celest.dart index 1025477e..2f46e12d 100644 --- a/examples/gemini/celest/lib/src/generated/cloud.celest.dart +++ b/examples/gemini/celest/lib/src/generated/cloud.celest.dart @@ -23,16 +23,16 @@ class CelestCloud { /// The current environment of the Celest service. /// - /// This is determined by the `CELEST_ENVIRONMENT` environment variable + /// This is determined by the `CELEST_ENVIRONMENT` variable /// which is set for you by the deployment environment. CelestEnvironment get currentEnvironment => - (env.currentEnvironment as CelestEnvironment); + (variables.currentEnvironment as CelestEnvironment); - /// The environment variables for the Celest service. + /// The variables of the Celest service. /// - /// This class provides access to the environment variable values - /// that are configured for the [currentEnvironment]. - CelestEnvironmentVariables get env => const CelestEnvironmentVariables(); + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); /// The secrets for the Celest service. /// diff --git a/examples/gemini/celest/lib/src/generated/config.celest.dart b/examples/gemini/celest/lib/src/generated/config.celest.dart index 01e982d0..1c27dd4f 100644 --- a/examples/gemini/celest/lib/src/generated/config.celest.dart +++ b/examples/gemini/celest/lib/src/generated/config.celest.dart @@ -34,8 +34,8 @@ extension type const CelestEnvironment._(String _env) /// /// This class provides access to the environment variable values /// that are configured for the current [CelestEnvironment]. -class CelestEnvironmentVariables { - const CelestEnvironmentVariables(); +class CelestVariables { + const CelestVariables(); /// The environment variable that determines the current environment. /// diff --git a/examples/gemini/celest/pubspec.yaml b/examples/gemini/celest/pubspec.yaml index c815c652..f5553c00 100644 --- a/examples/gemini/celest/pubspec.yaml +++ b/examples/gemini/celest/pubspec.yaml @@ -6,13 +6,18 @@ environment: sdk: ^3.4.0 dependencies: - celest: '^1.0.0-0' - google_generative_ai: '^0.2.0' + celest: ^1.0.0-0 + celest_ast: ^0.1.0 + celest_core: ^1.0.0-0 + google_generative_ai: ^0.2.0 http: '>=0.13.0 <2.0.0' + meta: ^1.12.0 dependency_overrides: celest: path: ../../../packages/celest + celest_ast: + path: ../../../packages/celest_ast celest_auth: path: ../../../packages/celest_auth celest_cloud: @@ -21,5 +26,5 @@ dependency_overrides: path: ../../../packages/celest_core dev_dependencies: - lints: '^4.0.0' - test: '^1.25.0' + lints: ^4.0.0 + test: ^1.25.0 diff --git a/examples/openai/celest/client/lib/openai_example_client.dart b/examples/openai/celest/client/lib/openai_example_client.dart index 423f8ac2..ed581794 100644 --- a/examples/openai/celest/client/lib/openai_example_client.dart +++ b/examples/openai/celest/client/lib/openai_example_client.dart @@ -23,8 +23,8 @@ enum CelestEnvironment { Uri get baseUri => switch (this) { local => _$celest.kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:55828') - : Uri.parse('http://10.0.2.2:55828'), + ? Uri.parse('http://localhost:55829') + : Uri.parse('http://10.0.2.2:55829'), }; } diff --git a/examples/openai/celest/client/lib/src/functions.dart b/examples/openai/celest/client/lib/src/functions.dart index 3e674eff..a0e6b26b 100644 --- a/examples/openai/celest/client/lib/src/functions.dart +++ b/examples/openai/celest/client/lib/src/functions.dart @@ -21,119 +21,246 @@ class CelestFunctions { class CelestFunctionsOpenAi { Never _throwError({ - required int? $statusCode, - required Map $body, + int? code, + required Map body, }) { - final $error = ($body['@error'] as Map?); - $statusCode ??= ($error?['status'] as num?)?.toInt(); - final $code = ($error?['code'] as String); - final $message = ($body['message'] as String?); - final $details = ($body['@'] as _$celest.JsonValue?) ?? - ($body['details'] as _$celest.JsonMap?); - switch ($code) { - case r'dart.convert.JsonUnsupportedObjectError': - throw _$celest.Serializers.instance - .deserialize<_$convert.JsonUnsupportedObjectError>($body); - case r'dart.async.AsyncError': - throw _$celest.Serializers.instance - .deserialize<_$async.AsyncError>($body); - case r'dart.async.TimeoutException': - throw _$celest.Serializers.instance - .deserialize<_$async.TimeoutException>($body); - case r'dart.core.Error': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.AssertionError': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.TypeError': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.ArgumentError': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.RangeError': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.IndexError': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.UnsupportedError': - throw _$celest.Serializers.instance - .deserialize($body); - case r'dart.core.UnimplementedError': - throw _$celest.Serializers.instance - .deserialize($body); - case r'dart.core.StateError': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.ConcurrentModificationError': - throw _$celest.Serializers.instance - .deserialize($body); - case r'dart.core.OutOfMemoryError': - throw _$celest.Serializers.instance - .deserialize($body); - case r'dart.core.StackOverflowError': - throw _$celest.Serializers.instance - .deserialize($body); - case r'dart.core.FormatException': - throw _$celest.Serializers.instance.deserialize($body); - case r'dart.core.IntegerDivisionByZeroException': - throw _$celest.Serializers.instance - .deserialize($body); - case r'celest.core.v1.CloudException': - throw _$celest.Serializers.instance - .deserialize<_$celest.CloudException>($body); - case r'celest.core.v1.CancelledException': - throw _$celest.Serializers.instance - .deserialize<_$celest.CancelledException>($body); - case r'celest.core.v1.UnknownError': - throw _$celest.Serializers.instance - .deserialize<_$celest.UnknownError>($body); - case r'celest.core.v1.BadRequestException': - throw _$celest.Serializers.instance - .deserialize<_$celest.BadRequestException>($body); - case r'celest.core.v1.UnauthorizedException': - throw _$celest.Serializers.instance - .deserialize<_$celest.UnauthorizedException>($body); - case r'celest.core.v1.NotFoundException': - throw _$celest.Serializers.instance - .deserialize<_$celest.NotFoundException>($body); - case r'celest.core.v1.AlreadyExistsException': - throw _$celest.Serializers.instance - .deserialize<_$celest.AlreadyExistsException>($body); - case r'celest.core.v1.PermissionDeniedException': - throw _$celest.Serializers.instance - .deserialize<_$celest.PermissionDeniedException>($body); - case r'celest.core.v1.ResourceExhaustedException': - throw _$celest.Serializers.instance - .deserialize<_$celest.ResourceExhaustedException>($body); - case r'celest.core.v1.FailedPreconditionException': - throw _$celest.Serializers.instance - .deserialize<_$celest.FailedPreconditionException>($body); - case r'celest.core.v1.AbortedException': - throw _$celest.Serializers.instance - .deserialize<_$celest.AbortedException>($body); - case r'celest.core.v1.OutOfRangeException': - throw _$celest.Serializers.instance - .deserialize<_$celest.OutOfRangeException>($body); - case r'celest.core.v1.UnimplementedError': - throw _$celest.Serializers.instance - .deserialize<_$celest.UnimplementedError>($body); - case r'celest.core.v1.InternalServerError': - throw _$celest.Serializers.instance - .deserialize<_$celest.InternalServerError>($body); - case r'celest.core.v1.UnavailableError': - throw _$celest.Serializers.instance - .deserialize<_$celest.UnavailableError>($body); - case r'celest.core.v1.DataLossError': - throw _$celest.Serializers.instance - .deserialize<_$celest.DataLossError>($body); - case r'celest.core.v1.DeadlineExceededError': - throw _$celest.Serializers.instance - .deserialize<_$celest.DeadlineExceededError>($body); - case r'celest.core.v1.SerializationException': - throw _$celest.Serializers.instance - .deserialize<_$celest.SerializationException>($body); + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String + }, + ... + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$convert.JsonUnsupportedObjectError>(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.AsyncError>(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.TimeoutException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CloudException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnknownError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.NotFoundException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AbortedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnavailableError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DataLossError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); default: - throw _$celest.CloudException.http( - status: $statusCode, - code: $code, - message: $message, - details: $details, + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, ); } } @@ -146,13 +273,16 @@ class CelestFunctionsOpenAi { Future> availableModels() async { final $response = await celest.httpClient.post( celest.baseUri.resolve('/open-ai/available-models'), - headers: {'Content-Type': 'application/json; charset=utf-8'}, + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, ); - final $body = _$convert.jsonDecode($response.body); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); if ($response.statusCode != 200) { _throwError( - $statusCode: $response.statusCode, - $body: $body, + code: $response.statusCode, + body: ($body as Map), ); } return ($body as Iterable).map((el) => (el as String)).toList(); @@ -180,7 +310,7 @@ class CelestFunctionsOpenAi { }); return $channel.stream.map(($event) { if ($event is Map && $event.containsKey('@error')) { - _throwError($statusCode: -1, $body: $event); + _throwError(body: $event); } return ($event as String); }); diff --git a/examples/openai/celest/client/lib/src/serializers.dart b/examples/openai/celest/client/lib/src/serializers.dart index e8e523b1..ec16f728 100644 --- a/examples/openai/celest/client/lib/src/serializers.dart +++ b/examples/openai/celest/client/lib/src/serializers.dart @@ -229,6 +229,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.AbortedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -240,6 +241,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.AbortedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -251,6 +253,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.AlreadyExistsException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -262,6 +265,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.AlreadyExistsException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -273,6 +277,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.BadRequestException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -284,6 +289,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.BadRequestException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -295,6 +301,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.CancelledException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -306,6 +313,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.CancelledException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -317,6 +325,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.CloudException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -332,6 +341,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.DataLossError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -343,6 +353,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.DataLossError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -354,6 +365,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.DeadlineExceededError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -365,6 +377,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.DeadlineExceededError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -376,6 +389,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.FailedPreconditionException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -387,6 +401,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.FailedPreconditionException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -398,6 +413,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.InternalServerError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -409,6 +425,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.InternalServerError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -420,6 +437,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.NotFoundException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -431,6 +449,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.NotFoundException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -442,6 +461,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.OutOfRangeException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -453,6 +473,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.OutOfRangeException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -464,6 +485,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.PermissionDeniedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -475,6 +497,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.PermissionDeniedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -486,6 +509,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.ResourceExhaustedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -497,6 +521,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.ResourceExhaustedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -508,6 +533,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.UnauthorizedException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -519,6 +545,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.UnauthorizedException( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -530,6 +557,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.UnavailableError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -541,6 +569,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.UnavailableError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -550,8 +579,9 @@ void initSerializers({_$celest.Serializers? serializers}) { }, )); _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnimplementedError, Map?>( + _$celest.UnimplementedError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -562,12 +592,20 @@ void initSerializers({_$celest.Serializers? serializers}) { }, deserialize: ($serialized) { return _$celest.UnimplementedError( - ($serialized?[r'message'] as String?)); + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); }, )); _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.UnknownError, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, @@ -579,6 +617,7 @@ void initSerializers({_$celest.Serializers? serializers}) { deserialize: ($serialized) { return _$celest.UnknownError( ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( $serialized[r'details'], @@ -590,6 +629,7 @@ void initSerializers({_$celest.Serializers? serializers}) { _$celest.Serializers.instance.put(_$celest.Serializer.define< _$celest.SerializationException, Map>( serialize: ($value) => { + r'code': $value.code, r'message': $value.message, if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( $value.details, diff --git a/examples/openai/celest/client/pubspec.yaml b/examples/openai/celest/client/pubspec.yaml index 16c4d8ff..76164d3f 100644 --- a/examples/openai/celest/client/pubspec.yaml +++ b/examples/openai/celest/client/pubspec.yaml @@ -6,21 +6,26 @@ environment: sdk: ^3.4.0 dependencies: + celest: ^1.0.0-0 celest_backend: path: .. - celest: '^1.0.0-0' - celest_core: '^1.0.0-0' - meta: '^1.12.0' - native_storage: '^0.2.2' + celest_core: ^1.0.0-0 + http: ^1.0.0 + meta: ^1.12.0 + native_storage: ^0.2.2 -dev_dependencies: {} +dev_dependencies: + lints: ^4.0.0 + test: ^1.25.0 dependency_overrides: celest: path: ../../../../packages/celest - celest_core: - path: ../../../../packages/celest_core + celest_ast: + path: ../../../../packages/celest_ast celest_auth: path: ../../../../packages/celest_auth celest_cloud: path: ../../../../packages/celest_cloud + celest_core: + path: ../../../../packages/celest_core diff --git a/examples/openai/celest/lib/src/generated/cloud.celest.dart b/examples/openai/celest/lib/src/generated/cloud.celest.dart index 1025477e..2f46e12d 100644 --- a/examples/openai/celest/lib/src/generated/cloud.celest.dart +++ b/examples/openai/celest/lib/src/generated/cloud.celest.dart @@ -23,16 +23,16 @@ class CelestCloud { /// The current environment of the Celest service. /// - /// This is determined by the `CELEST_ENVIRONMENT` environment variable + /// This is determined by the `CELEST_ENVIRONMENT` variable /// which is set for you by the deployment environment. CelestEnvironment get currentEnvironment => - (env.currentEnvironment as CelestEnvironment); + (variables.currentEnvironment as CelestEnvironment); - /// The environment variables for the Celest service. + /// The variables of the Celest service. /// - /// This class provides access to the environment variable values - /// that are configured for the [currentEnvironment]. - CelestEnvironmentVariables get env => const CelestEnvironmentVariables(); + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); /// The secrets for the Celest service. /// diff --git a/examples/openai/celest/lib/src/generated/config.celest.dart b/examples/openai/celest/lib/src/generated/config.celest.dart index bc00db8b..f801d6c6 100644 --- a/examples/openai/celest/lib/src/generated/config.celest.dart +++ b/examples/openai/celest/lib/src/generated/config.celest.dart @@ -34,8 +34,8 @@ extension type const CelestEnvironment._(String _env) /// /// This class provides access to the environment variable values /// that are configured for the current [CelestEnvironment]. -class CelestEnvironmentVariables { - const CelestEnvironmentVariables(); +class CelestVariables { + const CelestVariables(); /// The environment variable that determines the current environment. /// diff --git a/examples/openai/celest/pubspec.yaml b/examples/openai/celest/pubspec.yaml index dc02b563..cdf101d0 100644 --- a/examples/openai/celest/pubspec.yaml +++ b/examples/openai/celest/pubspec.yaml @@ -6,13 +6,18 @@ environment: sdk: ^3.4.0 dependencies: - celest: '^1.0.0-0' - chat_gpt_sdk: '^2.2.8' + celest: ^1.0.0-0 + celest_ast: ^0.1.0 + celest_core: ^1.0.0-0 + chat_gpt_sdk: ^2.2.8 http: '>=0.13.0 <2.0.0' + meta: ^1.12.0 dependency_overrides: celest: path: ../../../packages/celest + celest_ast: + path: ../../../packages/celest_ast celest_auth: path: ../../../packages/celest_auth celest_cloud: @@ -21,5 +26,5 @@ dependency_overrides: path: ../../../packages/celest_core dev_dependencies: - lints: '^4.0.0' - test: '^1.25.0' + lints: ^4.0.0 + test: ^1.25.0 diff --git a/packages/celest/example/celest/client/lib/example_client.dart b/packages/celest/example/celest/client/lib/example_client.dart index aecee4b1..94733f8d 100644 --- a/packages/celest/example/celest/client/lib/example_client.dart +++ b/packages/celest/example/celest/client/lib/example_client.dart @@ -1,19 +1,19 @@ // Generated by Celest. This file should not be modified manually, but // it can be checked into version control. -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use library; // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:io' as _$io; import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.dart' as _$celest; import 'package:celest_core/src/util/globals.dart' as _$celest; +import 'package:example_client/src/functions.dart'; +import 'package:example_client/src/serializers.dart'; 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'; - export 'package:celest_backend/exceptions/bad_name_exception.dart' show BadNameException; export 'package:celest_backend/models/person.dart' show Person; @@ -25,8 +25,8 @@ enum CelestEnvironment { Uri get baseUri => switch (this) { local => _$celest.kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:52794') - : Uri.parse('http://10.0.2.2:52794'), + ? Uri.parse('http://localhost:52795') + : Uri.parse('http://10.0.2.2:52795'), }; } @@ -62,11 +62,14 @@ class Celest with _$celest.CelestBase { CelestFunctions get functions => _checkInitialized(() => _functions); - void init({CelestEnvironment environment = CelestEnvironment.local}) { + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { _currentEnvironment = environment; _baseUri = environment.baseUri; if (!_initialized) { - initSerializers(); + initSerializers(serializers: serializers); } _initialized = true; } diff --git a/packages/celest/example/celest/client/lib/src/functions.dart b/packages/celest/example/celest/client/lib/src/functions.dart index 193746e0..d13b7cd4 100644 --- a/packages/celest/example/celest/client/lib/src/functions.dart +++ b/packages/celest/example/celest/client/lib/src/functions.dart @@ -1,9 +1,10 @@ // Generated by Celest. This file should not be modified manually, but // it can be checked into version control. -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use library; // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _$async; import 'dart:convert' as _$convert; import 'package:celest/celest.dart' as _$celest; @@ -13,8 +14,7 @@ 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'; +import 'package:example_client/example_client.dart'; class CelestFunctions { final greeting = CelestFunctionsGreeting(); @@ -22,77 +22,252 @@ class CelestFunctions { class CelestFunctionsGreeting { Never _throwError({ - required int $statusCode, - required Map $body, + int? code, + required Map body, }) { - final $error = ($body['error'] as Map); - final $code = ($error['code'] as String); - 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($details); + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String + }, + ... + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CloudException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnknownError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.NotFoundException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AbortedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnavailableError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DataLossError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.AsyncError>(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.TimeoutException>(errorValue), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$convert.JsonUnsupportedObjectError>(errorValue), + stackTrace, + ); + case 'example.v1.BadNameException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); default: - throw _$celest.CloudException.http( - status: $statusCode, - code: $code, - message: $message, - details: $details, + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, ); } } @@ -105,18 +280,20 @@ class CelestFunctionsGreeting { Future sayHello({required Person person}) async { final $response = await celest.httpClient.post( celest.baseUri.resolve('/greeting/say-hello'), - headers: {'Content-Type': 'application/json; charset=utf-8'}, - body: _$convert.jsonEncode( + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: _$celest.JsonUtf8.encode( {r'person': _$celest.Serializers.instance.serialize(person)}), ); - final $body = - (_$convert.jsonDecode($response.body) as Map); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); if ($response.statusCode != 200) { _throwError( - $statusCode: $response.statusCode, - $body: $body, + code: $response.statusCode, + body: ($body as Map), ); } - return ($body['response'] as String); + return ($body as String); } } diff --git a/packages/celest/example/celest/client/lib/src/serializers.dart b/packages/celest/example/celest/client/lib/src/serializers.dart index d10e1248..a7ead59d 100644 --- a/packages/celest/example/celest/client/lib/src/serializers.dart +++ b/packages/celest/example/celest/client/lib/src/serializers.dart @@ -1,6 +1,9 @@ -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _$async; +import 'dart:convert' as _$convert; + 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; @@ -9,355 +12,649 @@ import 'package:celest_core/src/exception/serialization_exception.dart' as _$celest; import 'package:celest_core/src/serialization/json_value.dart' as _$celest; -void initSerializers() { - _$celest.Serializers.instance - .put(_$celest.Serializer.define>( - serialize: ($value) => {r'message': $value.message}, - deserialize: ($serialized) { - return BadNameException(($serialized[r'message'] as String)); - }, - )); - _$celest.Serializers.instance - .put(_$celest.Serializer.define>( - serialize: ($value) => {r'name': $value.name}, - deserialize: ($serialized) { - return Person(name: ($serialized[r'name'] as String)); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.AbortedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.AbortedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.AlreadyExistsException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.AlreadyExistsException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.BadRequestException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.BadRequestException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.CancelledException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.CancelledException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.CloudException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.CloudException.fromJson($serialized); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.DataLossError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.DataLossError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), +void initSerializers({_$celest.Serializers? serializers}) { + return _$async.runZoned( + () { + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$async.AsyncError, Map>( + serialize: ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return _$async.AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance + .deserialize($serialized[r'stackTrace']), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$async.TimeoutException, Map>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance + .serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _$async.TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance + .deserialize($serialized[r'duration']), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$convert.JsonUnsupportedObjectError, Map>( + serialize: ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _$convert.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define?>( + serialize: ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + ConcurrentModificationError, Map?>( + serialize: ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define?>( + serialize: ($value) => { + if (_$celest.Serializers.instance + .serialize($value.stackTrace) + case final stackTrace?) + r'stackTrace': stackTrace + }, + deserialize: ($serialized) { + return Error(); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define>( + serialize: ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + IntegerDivisionByZeroException, Map?>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define>( + serialize: ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return BadNameException(($serialized[r'message'] as String)); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define>( + serialize: ($value) => {r'name': $value.name}, + deserialize: ($serialized) { + return Person(name: ($serialized[r'name'] as String)); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.AbortedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.AlreadyExistsException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.BadRequestException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.CancelledException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.CloudException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.DataLossError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.DeadlineExceededError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.FailedPreconditionException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.InternalServerError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.NotFoundException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.OutOfRangeException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.PermissionDeniedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.ResourceExhaustedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnauthorizedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnavailableError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnimplementedError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnknownError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.SerializationException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String)); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.DeadlineExceededError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.DeadlineExceededError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.FailedPreconditionException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.FailedPreconditionException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.InternalServerError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.InternalServerError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), ); }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.NotFoundException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.NotFoundException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.OutOfRangeException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.OutOfRangeException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.PermissionDeniedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.PermissionDeniedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.ResourceExhaustedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.ResourceExhaustedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnauthorizedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnauthorizedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnavailableError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnavailableError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnimplementedError, Map?>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnimplementedError(($serialized?[r'message'] as String?)); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.UnknownError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnknownError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.SerializationException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'offset': $value.offset, - r'source': $value.source, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.SerializationException( - ($serialized[r'message'] as String)); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.JsonValue, Object>( - serialize: ($value) => $value.value, - deserialize: ($serialized) { - return _$celest.JsonValue($serialized); - }, - ), - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + zoneValues: {_$celest.Serializers: serializers}, ); } diff --git a/packages/celest/example/celest/client/pubspec.yaml b/packages/celest/example/celest/client/pubspec.yaml index 348816df..1b718e74 100644 --- a/packages/celest/example/celest/client/pubspec.yaml +++ b/packages/celest/example/celest/client/pubspec.yaml @@ -6,11 +6,14 @@ environment: sdk: ^3.4.0 dependencies: - celest: ^0.5.0-0 + celest: ^1.0.0-0 celest_backend: path: ../ - celest_core: ^0.5.0-0 - http: ">=0.13.0 <2.0.0" + celest_core: ^1.0.0-0 + http: ^1.0.0 + native_storage: ^0.2.2 dev_dependencies: - test: + lints: ^4.0.0 + test: ^1.25.0 +dependency_overrides: {} diff --git a/packages/celest/example/celest/lib/src/generated/cloud.celest.dart b/packages/celest/example/celest/lib/src/generated/cloud.celest.dart new file mode 100644 index 00000000..2f46e12d --- /dev/null +++ b/packages/celest/example/celest/lib/src/generated/cloud.celest.dart @@ -0,0 +1,42 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use + +library; + +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); + + /// The secrets for the Celest service. + /// + /// This class provides access to the secret values that are configured + /// for the [currentEnvironment]. + CelestSecrets get secrets => const CelestSecrets(); +} diff --git a/packages/celest/example/celest/lib/src/generated/config.celest.dart b/packages/celest/example/celest/lib/src/generated/config.celest.dart new file mode 100644 index 00000000..cf6e0105 --- /dev/null +++ b/packages/celest/example/celest/lib/src/generated/config.celest.dart @@ -0,0 +1,53 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} + +/// The secrets for the Celest service. +/// +/// This class provides access to the secret values that are configured +/// for the current [CelestEnvironment]. +class CelestSecrets { + const CelestSecrets(); +} diff --git a/packages/celest/example/celest/lib/src/generated/resources.dart b/packages/celest/example/celest/lib/src/generated/resources.dart deleted file mode 100644 index ffc4fd72..00000000 --- a/packages/celest/example/celest/lib/src/generated/resources.dart +++ /dev/null @@ -1,5 +0,0 @@ -// Generated by Celest. This file should not be modified manually, but -// it can be checked into version control. -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import - -library; diff --git a/packages/celest/example/celest/lib/src/project.dart b/packages/celest/example/celest/lib/src/project.dart new file mode 100644 index 00000000..5f6c5a24 --- /dev/null +++ b/packages/celest/example/celest/lib/src/project.dart @@ -0,0 +1,5 @@ +import 'package:celest/celest.dart'; + +const project = Project( + name: 'example', +); diff --git a/packages/celest/example/celest/project.dart b/packages/celest/example/celest/project.dart deleted file mode 100644 index 5f6c5a24..00000000 --- a/packages/celest/example/celest/project.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:celest/celest.dart'; - -const project = Project( - name: 'example', -); diff --git a/packages/celest/example/celest/project.dart b/packages/celest/example/celest/project.dart new file mode 120000 index 00000000..5e1a005c --- /dev/null +++ b/packages/celest/example/celest/project.dart @@ -0,0 +1 @@ +/Users/dillonnys/celest/cloud/celest/packages/celest/example/celest/lib/src/project.dart \ No newline at end of file diff --git a/packages/celest/example/celest/pubspec.yaml b/packages/celest/example/celest/pubspec.yaml index 89347f61..60b9e149 100644 --- a/packages/celest/example/celest/pubspec.yaml +++ b/packages/celest/example/celest/pubspec.yaml @@ -6,8 +6,11 @@ environment: sdk: ^3.4.0 dependencies: - celest: ^0.5.0-0 - http: ">=0.13.0 <2.0.0" + celest: ^1.0.0-0 + celest_ast: ^0.1.0 + celest_core: ^1.0.0-0 + http: '>=0.13.0 <2.0.0' + meta: ^1.12.0 dependency_overrides: celest: diff --git a/packages/celest_auth/example/celest/client/lib/celest_auth_example_client.dart b/packages/celest_auth/example/celest/client/lib/celest_auth_example_client.dart index af4dbfa0..2622a0e4 100644 --- a/packages/celest_auth/example/celest/client/lib/celest_auth_example_client.dart +++ b/packages/celest_auth/example/celest/client/lib/celest_auth_example_client.dart @@ -1,22 +1,23 @@ // Generated by Celest. This file should not be modified manually, but // it can be checked into version control. -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use library; // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _$async; import 'dart:io' as _$io; +import 'package:celest_auth_example_client/src/auth.dart'; +import 'package:celest_auth_example_client/src/functions.dart'; +import 'package:celest_auth_example_client/src/serializers.dart'; import 'package:celest_core/_internal.dart' as _$celest; +import 'package:celest_core/celest_core.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/auth.dart'; -import 'src/functions.dart'; -import 'src/serializers.dart'; - export 'package:celest_auth/celest_auth.dart'; +export 'src/auth.dart'; final Celest celest = Celest(); @@ -25,8 +26,8 @@ enum CelestEnvironment { Uri get baseUri => switch (this) { local => _$celest.kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:7780') - : Uri.parse('http://10.0.2.2:7780'), + ? Uri.parse('http://localhost:7782') + : Uri.parse('http://10.0.2.2:7782'), }; } @@ -69,7 +70,10 @@ class Celest with _$celest.CelestBase { CelestAuth get auth => _checkInitialized(() => _auth); - void init({CelestEnvironment environment = CelestEnvironment.local}) { + void init({ + CelestEnvironment environment = CelestEnvironment.local, + _$celest.Serializers? serializers, + }) { if (_initialized && environment != _currentEnvironment) { _auth.signOut(); } @@ -77,7 +81,7 @@ class Celest with _$celest.CelestBase { _baseUri = environment.baseUri; _$async.scheduleMicrotask(_auth.init); if (!_initialized) { - initSerializers(); + initSerializers(serializers: serializers); } _initialized = true; } diff --git a/packages/celest_auth/example/celest/client/lib/src/auth.dart b/packages/celest_auth/example/celest/client/lib/src/auth.dart index 2237c787..76a280a7 100644 --- a/packages/celest_auth/example/celest/client/lib/src/auth.dart +++ b/packages/celest_auth/example/celest/client/lib/src/auth.dart @@ -1,6 +1,6 @@ // Generated by Celest. This file should not be modified manually, but // it can be checked into version control. -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use library; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/celest_auth/example/celest/client/lib/src/functions.dart b/packages/celest_auth/example/celest/client/lib/src/functions.dart index 41c38696..3a37e685 100644 --- a/packages/celest_auth/example/celest/client/lib/src/functions.dart +++ b/packages/celest_auth/example/celest/client/lib/src/functions.dart @@ -1,93 +1,265 @@ // Generated by Celest. This file should not be modified manually, but // it can be checked into version control. -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use library; // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _$async; import 'dart:convert' as _$convert; import 'package:celest/celest.dart' as _$celest; +import 'package:celest_auth_example_client/celest_auth_example_client.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 '../celest_auth_example_client.dart'; - class CelestFunctions { final greeting = CelestFunctionsGreeting(); } class CelestFunctionsGreeting { Never _throwError({ - required int $statusCode, - required Map $body, + int? code, + required Map body, }) { - final $error = ($body['error'] as Map); - final $code = ($error['code'] as String); - 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); + final status = body['@status'] as Map?; + final message = status?['message'] as String?; + final details = status?['details'] as _$celest.JsonList?; + final (errorType, errorValue, stackTrace) = switch (details) { + null || [] => const (null, null, StackTrace.empty), + [ + final errorDetails as Map, + { + '@type': 'dart.core.StackTrace', + 'value': final stackTraceValue as String + }, + ... + ] => + ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.fromString(stackTraceValue), + ), + [final errorDetails as Map, ...] => ( + errorDetails['@type'], + errorDetails['value'], + StackTrace.empty, + ), + }; + + switch (errorType) { + case 'celest.core.v1.CloudException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CloudException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.CancelledException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.CancelledException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnknownError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnknownError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.BadRequestException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.BadRequestException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnauthorizedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnauthorizedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.NotFoundException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.NotFoundException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AlreadyExistsException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AlreadyExistsException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.PermissionDeniedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.PermissionDeniedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.ResourceExhaustedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.ResourceExhaustedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.FailedPreconditionException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.FailedPreconditionException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.AbortedException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.AbortedException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.OutOfRangeException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.OutOfRangeException>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnimplementedError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.InternalServerError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.InternalServerError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.UnavailableError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.UnavailableError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DataLossError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DataLossError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.DeadlineExceededError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.DeadlineExceededError>(errorValue), + stackTrace, + ); + case 'celest.core.v1.SerializationException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$celest.SerializationException>(errorValue), + stackTrace, + ); + case 'dart.core.Error': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.AssertionError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.TypeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ArgumentError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.RangeError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IndexError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnsupportedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.UnimplementedError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StateError': + Error.throwWithStackTrace( + _$celest.Serializers.instance.deserialize(errorValue), + stackTrace, + ); + case 'dart.core.ConcurrentModificationError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.OutOfMemoryError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.StackOverflowError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.FormatException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.core.IntegerDivisionByZeroException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize(errorValue), + stackTrace, + ); + case 'dart.async.AsyncError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.AsyncError>(errorValue), + stackTrace, + ); + case 'dart.async.TimeoutException': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$async.TimeoutException>(errorValue), + stackTrace, + ); + case 'dart.convert.JsonUnsupportedObjectError': + Error.throwWithStackTrace( + _$celest.Serializers.instance + .deserialize<_$convert.JsonUnsupportedObjectError>(errorValue), + stackTrace, + ); default: - throw _$celest.CloudException.http( - status: $statusCode, - code: $code, - message: $message, - details: $details, + Error.throwWithStackTrace( + _$celest.CloudException.http( + code: code, + message: message, + details: ((details ?? body) as _$celest.JsonValue), + ), + StackTrace.empty, ); } } @@ -100,16 +272,18 @@ class CelestFunctionsGreeting { Future sayHello() async { final $response = await celest.httpClient.post( celest.baseUri.resolve('/greeting/say-hello'), - headers: {'Content-Type': 'application/json; charset=utf-8'}, + headers: const { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, ); - final $body = - (_$convert.jsonDecode($response.body) as Map); + final $body = _$celest.JsonUtf8.decode($response.bodyBytes); if ($response.statusCode != 200) { _throwError( - $statusCode: $response.statusCode, - $body: $body, + code: $response.statusCode, + body: ($body as Map), ); } - return ($body['response'] as String); + return ($body as String); } } diff --git a/packages/celest_auth/example/celest/client/lib/src/serializers.dart b/packages/celest_auth/example/celest/client/lib/src/serializers.dart index f7b52d22..c77a696d 100644 --- a/packages/celest_auth/example/celest/client/lib/src/serializers.dart +++ b/packages/celest_auth/example/celest/client/lib/src/serializers.dart @@ -1,347 +1,644 @@ -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _$async; +import 'dart:convert' as _$convert; + 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 'package:celest_core/src/serialization/json_value.dart' as _$celest; -void initSerializers() { - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.AbortedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.AbortedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), +void initSerializers({_$celest.Serializers? serializers}) { + return _$async.runZoned( + () { + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$async.AsyncError, Map>( + serialize: ($value) => { + r'error': $value.error, + r'stackTrace': _$celest.Serializers.instance + .serialize($value.stackTrace), + }, + deserialize: ($serialized) { + return _$async.AsyncError( + $serialized[r'error']!, + _$celest.Serializers.instance + .deserialize($serialized[r'stackTrace']), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$async.TimeoutException, Map>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message, + if (_$celest.Serializers.instance + .serialize($value.duration) + case final duration?) + r'duration': duration, + }, + deserialize: ($serialized) { + return _$async.TimeoutException( + ($serialized[r'message'] as String?), + _$celest.Serializers.instance + .deserialize($serialized[r'duration']), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$convert.JsonUnsupportedObjectError, Map>( + serialize: ($value) => { + if ($value.unsupportedObject case final unsupportedObject?) + r'unsupportedObject': unsupportedObject, + if ($value.cause case final cause?) r'cause': cause, + if ($value.partialResult case final partialResult?) + r'partialResult': partialResult, + }, + deserialize: ($serialized) { + return _$convert.JsonUnsupportedObjectError( + $serialized[r'unsupportedObject'], + cause: $serialized[r'cause'], + partialResult: ($serialized[r'partialResult'] as String?), + ); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define?>( + serialize: ($value) => { + r'invalidValue': $value.invalidValue, + if ($value.name case final name?) r'name': name, + r'message': $value.message, + }, + deserialize: ($serialized) { + return ArgumentError( + $serialized?[r'message'], + ($serialized?[r'name'] as String?), + ); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return AssertionError($serialized?[r'message']); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + ConcurrentModificationError, Map?>( + serialize: ($value) => { + if ($value.modifiedObject case final modifiedObject?) + r'modifiedObject': modifiedObject + }, + deserialize: ($serialized) { + return ConcurrentModificationError($serialized?[r'modifiedObject']); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define?>( + serialize: ($value) => { + if (_$celest.Serializers.instance + .serialize($value.stackTrace) + case final stackTrace?) + r'stackTrace': stackTrace + }, + deserialize: ($serialized) { + return Error(); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => { + r'message': $value.message, + r'source': $value.source, + if ($value.offset case final offset?) r'offset': offset, + }, + deserialize: ($serialized) { + return FormatException( + (($serialized?[r'message'] as String?)) ?? '', + $serialized?[r'source'], + ($serialized?[r'offset'] as num?)?.toInt(), + ); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define>( + serialize: ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.indexable case final indexable?) r'indexable': indexable, + r'length': $value.length, + r'invalidValue': $value.invalidValue, + r'start': $value.start, + r'end': $value.end, + }, + deserialize: ($serialized) { + return IndexError( + ($serialized[r'invalidValue'] as num).toInt(), + $serialized[r'indexable'], + ($serialized[r'name'] as String?), + ($serialized[r'message'] as String?), + ($serialized[r'length'] as num?)?.toInt(), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + IntegerDivisionByZeroException, Map?>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return IntegerDivisionByZeroException(); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return OutOfMemoryError(); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define>( + serialize: ($value) => { + if ($value.name case final name?) r'name': name, + r'message': $value.message, + if ($value.start case final start?) r'start': start, + if ($value.end case final end?) r'end': end, + if ($value.invalidValue case final invalidValue?) + r'invalidValue': invalidValue, + }, + deserialize: ($serialized) { + return RangeError($serialized[r'message']); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return StackOverflowError(); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return StateError(($serialized[r'message'] as String)); + }, + )); + _$celest.Serializers.instance + .put(_$celest.Serializer.define?>( + serialize: ($value) => const {}, + deserialize: ($serialized) { + return TypeError(); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define?>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return UnimplementedError(($serialized?[r'message'] as String?)); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define>( + serialize: ($value) => { + if ($value.message case final message?) r'message': message + }, + deserialize: ($serialized) { + return UnsupportedError(($serialized[r'message'] as String)); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.AbortedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AbortedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.AlreadyExistsException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.AlreadyExistsException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.BadRequestException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.BadRequestException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.CancelledException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CancelledException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.CloudException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.CloudException.fromJson($serialized); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.DataLossError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DataLossError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.DeadlineExceededError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.DeadlineExceededError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.FailedPreconditionException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.FailedPreconditionException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.InternalServerError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.InternalServerError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.NotFoundException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.NotFoundException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.OutOfRangeException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.OutOfRangeException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.PermissionDeniedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.PermissionDeniedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.ResourceExhaustedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.ResourceExhaustedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnauthorizedException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnauthorizedException( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnavailableError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnavailableError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnimplementedError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnimplementedError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.UnknownError, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.UnknownError( + ($serialized[r'message'] as String?), + code: ($serialized[r'code'] as num?)?.toInt(), + details: + _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( + $serialized[r'details'], + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ), + ); + }, + )); + _$celest.Serializers.instance.put(_$celest.Serializer.define< + _$celest.SerializationException, Map>( + serialize: ($value) => { + r'code': $value.code, + r'message': $value.message, + if (_$celest.Serializers.instance.serialize<_$celest.JsonValue?>( + $value.details, + const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + ) + case final details?) + r'details': details, + }, + deserialize: ($serialized) { + return _$celest.SerializationException( + ($serialized[r'message'] as String)); + }, + )); + _$celest.Serializers.instance.put( + _$celest.Serializer.define<_$celest.JsonValue, Object>( + serialize: ($value) => $value.value, + deserialize: ($serialized) { + return _$celest.JsonValue($serialized); + }, ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.AlreadyExistsException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.AlreadyExistsException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), ); }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.BadRequestException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.BadRequestException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.CancelledException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.CancelledException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.CloudException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.CloudException.fromJson($serialized); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.DataLossError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.DataLossError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.DeadlineExceededError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.DeadlineExceededError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.FailedPreconditionException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.FailedPreconditionException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.InternalServerError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.InternalServerError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.NotFoundException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.NotFoundException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.OutOfRangeException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.OutOfRangeException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.PermissionDeniedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.PermissionDeniedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.ResourceExhaustedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.ResourceExhaustedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnauthorizedException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnauthorizedException( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnavailableError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnavailableError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.UnimplementedError, Map?>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnimplementedError(($serialized?[r'message'] as String?)); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.UnknownError, Map>( - serialize: ($value) => { - r'message': $value.message, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.UnknownError( - ($serialized[r'message'] as String?), - details: _$celest.Serializers.instance.deserialize<_$celest.JsonValue?>( - $serialized[r'details'], - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - ); - }, - )); - _$celest.Serializers.instance.put(_$celest.Serializer.define< - _$celest.SerializationException, Map>( - serialize: ($value) => { - r'message': $value.message, - r'offset': $value.offset, - r'source': $value.source, - r'details': _$celest.Serializers.instance.serialize<_$celest.JsonValue?>( - $value.details, - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), - ), - }, - deserialize: ($serialized) { - return _$celest.SerializationException( - ($serialized[r'message'] as String)); - }, - )); - _$celest.Serializers.instance.put( - _$celest.Serializer.define<_$celest.JsonValue, Object>( - serialize: ($value) => $value.value, - deserialize: ($serialized) { - return _$celest.JsonValue($serialized); - }, - ), - const _$celest.TypeToken<_$celest.JsonValue?>('JsonValue'), + zoneValues: {_$celest.Serializers: serializers}, ); } diff --git a/packages/celest_auth/example/celest/client/pubspec.yaml b/packages/celest_auth/example/celest/client/pubspec.yaml index d5120d24..7220dd3c 100644 --- a/packages/celest_auth/example/celest/client/pubspec.yaml +++ b/packages/celest_auth/example/celest/client/pubspec.yaml @@ -6,12 +6,24 @@ environment: sdk: ^3.4.0 dependencies: - celest: ^0.5.0-0 + celest: ^1.0.0-0 celest_backend: path: ../ - celest_core: ^0.5.0-0 - http: ">=0.13.0 <2.0.0" + celest_core: ^1.0.0-0 + http: ^1.0.0 native_storage: ^0.2.2 dev_dependencies: - test: + lints: ^4.0.0 + test: ^1.25.0 +dependency_overrides: + celest: + path: ../../../../celest + celest_ast: + path: ../../../../celest_ast + celest_auth: + path: ../../.. + celest_cloud: + path: ../../../../celest_cloud + celest_core: + path: ../../../../celest_core diff --git a/packages/celest_auth/example/celest/lib/src/generated/cloud.celest.dart b/packages/celest_auth/example/celest/lib/src/generated/cloud.celest.dart new file mode 100644 index 00000000..2f46e12d --- /dev/null +++ b/packages/celest_auth/example/celest/lib/src/generated/cloud.celest.dart @@ -0,0 +1,42 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use + +library; + +import 'package:celest_backend/src/generated/config.celest.dart'; + +/// The interface to your Celest backend. +/// +/// Similar to the `celest` global in the frontend, this +/// provides access to the backend environment and services +/// configured for your project. +const CelestCloud celest = CelestCloud._(); + +/// The interface to your Celest backend. +/// +/// Similar to the `Celest` class in the frontend, this class +/// provides access to the backend environment and services +/// configured for your project. +class CelestCloud { + const CelestCloud._(); + + /// The current environment of the Celest service. + /// + /// This is determined by the `CELEST_ENVIRONMENT` variable + /// which is set for you by the deployment environment. + CelestEnvironment get currentEnvironment => + (variables.currentEnvironment as CelestEnvironment); + + /// The variables of the Celest service. + /// + /// This class provides access to the values configured for the + /// [currentEnvironment]. + CelestVariables get variables => const CelestVariables(); + + /// The secrets for the Celest service. + /// + /// This class provides access to the secret values that are configured + /// for the [currentEnvironment]. + CelestSecrets get secrets => const CelestSecrets(); +} diff --git a/packages/celest_auth/example/celest/lib/src/generated/config.celest.dart b/packages/celest_auth/example/celest/lib/src/generated/config.celest.dart new file mode 100644 index 00000000..cf6e0105 --- /dev/null +++ b/packages/celest_auth/example/celest/lib/src/generated/config.celest.dart @@ -0,0 +1,53 @@ +// Generated by Celest. This file should not be modified manually, but +// it can be checked into version control. +// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import, deprecated_member_use + +library; + +import 'package:celest/celest.dart'; +import 'package:celest/src/core/context.dart'; + +/// An environment of a deployed Celest service. +/// +/// Celest services can have multiple isolated branches, for example +/// a `development` and `production` environment. +extension type const CelestEnvironment._(String _env) + implements Environment, String { + /// The local Celest environment, used to delineate when a + /// Celest service is running on a developer machine as opposed + /// to the cloud. + static const CelestEnvironment local = CelestEnvironment._('local'); + + /// The production Celest environment which is common to all + /// Celest projects and labels the environment which is considered + /// live and served to end-users. + static const CelestEnvironment production = CelestEnvironment._('production'); + + /// Whether `this` represents the [local] environment. + bool get isLocal => this == local; + + /// Whether `this` represents the [production] environment. + bool get isProduction => this == production; +} + +/// The environment variables for the Celest service. +/// +/// This class provides access to the environment variable values +/// that are configured for the current [CelestEnvironment]. +class CelestVariables { + const CelestVariables(); + + /// The environment variable that determines the current environment. + /// + /// This is set by the deployment environment and is used to + /// determine the current environment of the Celest service. + String get currentEnvironment => context.expect(env.environment); +} + +/// The secrets for the Celest service. +/// +/// This class provides access to the secret values that are configured +/// for the current [CelestEnvironment]. +class CelestSecrets { + const CelestSecrets(); +} diff --git a/packages/celest_auth/example/celest/lib/src/generated/resources.dart b/packages/celest_auth/example/celest/lib/src/generated/resources.dart deleted file mode 100644 index ffc4fd72..00000000 --- a/packages/celest_auth/example/celest/lib/src/generated/resources.dart +++ /dev/null @@ -1,5 +0,0 @@ -// Generated by Celest. This file should not be modified manually, but -// it can be checked into version control. -// ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import - -library; diff --git a/packages/celest_auth/example/celest/lib/src/project.dart b/packages/celest_auth/example/celest/lib/src/project.dart new file mode 100644 index 00000000..666172a2 --- /dev/null +++ b/packages/celest_auth/example/celest/lib/src/project.dart @@ -0,0 +1,12 @@ +import 'package:celest/celest.dart'; + +const project = Project( + name: 'celest_auth_example', +); + +const auth = Auth( + providers: [ + AuthProvider.email(), + AuthProvider.sms(), + ], +); diff --git a/packages/celest_auth/example/celest/project.dart b/packages/celest_auth/example/celest/project.dart deleted file mode 100644 index 666172a2..00000000 --- a/packages/celest_auth/example/celest/project.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:celest/celest.dart'; - -const project = Project( - name: 'celest_auth_example', -); - -const auth = Auth( - providers: [ - AuthProvider.email(), - AuthProvider.sms(), - ], -); diff --git a/packages/celest_auth/example/celest/project.dart b/packages/celest_auth/example/celest/project.dart new file mode 120000 index 00000000..cd39dccd --- /dev/null +++ b/packages/celest_auth/example/celest/project.dart @@ -0,0 +1 @@ +/Users/dillonnys/celest/cloud/celest/packages/celest_auth/example/celest/lib/src/project.dart \ No newline at end of file diff --git a/packages/celest_auth/example/celest/pubspec.yaml b/packages/celest_auth/example/celest/pubspec.yaml index ad55ebc0..a5ef3655 100644 --- a/packages/celest_auth/example/celest/pubspec.yaml +++ b/packages/celest_auth/example/celest/pubspec.yaml @@ -6,15 +6,19 @@ environment: sdk: ^3.4.0 dependencies: - celest: ^0.5.0-0 - http: ">=0.13.0 <2.0.0" - - celest_auth: any + celest: ^1.0.0-0 + celest_ast: ^0.1.0 + celest_auth: 'any' + celest_core: ^1.0.0-0 + http: '>=0.13.0 <2.0.0' + meta: ^1.12.0 dependency_overrides: celest: path: ../../../celest + celest_ast: + path: ../../../celest_ast celest_auth: - path: ../../ + path: ../.. celest_cloud: path: ../../../celest_cloud celest_core: