From 336ae8f8dd26165fcd2180cb40653efaffafff71 Mon Sep 17 00:00:00 2001 From: Dillon Nys Date: Fri, 1 Mar 2024 09:50:39 -0800 Subject: [PATCH] chore(examples): Update generated code --- examples/gemini/celest/lib/client.dart | 4 ++-- examples/gemini/celest/resources.dart | 9 +++++++++ examples/openai/celest/lib/client.dart | 9 ++++++--- examples/openai/celest/lib/src/client/functions.dart | 4 ++++ .../openai/celest/lib/src/client/serializers.dart | 12 ++++++++++++ examples/openai/celest/pubspec.lock | 4 ++-- examples/openai/celest/resources.dart | 9 +++++++++ examples/openai/pubspec.lock | 4 ++-- examples/todo/celest/lib/client.dart | 4 ++-- examples/todo/celest/pubspec.lock | 4 ++-- examples/todo/celest/resources.dart | 6 ++++++ examples/todo/pubspec.lock | 4 ++-- packages/celest/example/celest/lib/client.dart | 4 ++-- packages/celest/example/celest/resources.dart | 6 ++++++ 14 files changed, 66 insertions(+), 17 deletions(-) diff --git a/examples/gemini/celest/lib/client.dart b/examples/gemini/celest/lib/client.dart index 546780c3..1f1cfc16 100644 --- a/examples/gemini/celest/lib/client.dart +++ b/examples/gemini/celest/lib/client.dart @@ -19,8 +19,8 @@ enum CelestEnvironment { Uri get baseUri => switch (this) { local => kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:7781') - : Uri.parse('http://10.0.2.2:7781'), + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), }; } diff --git a/examples/gemini/celest/resources.dart b/examples/gemini/celest/resources.dart index 90db0e06..7ab178df 100644 --- a/examples/gemini/celest/resources.dart +++ b/examples/gemini/celest/resources.dart @@ -6,10 +6,16 @@ library; import 'package:celest/celest.dart'; +@Deprecated('Use `Apis` instead.') +typedef apis = Apis; + abstract final class Apis { static const gemini = CloudApi(name: r'gemini'); } +@Deprecated('Use `Functions` instead.') +typedef functions = Functions; + abstract final class Functions { static const geminiAvailableModels = CloudFunction( api: r'gemini', @@ -22,6 +28,9 @@ abstract final class Functions { ); } +@Deprecated('Use `Env` instead.') +typedef env = Env; + abstract final class Env { static const geminiApiKey = EnvironmentVariable(name: r'GEMINI_API_KEY'); } diff --git a/examples/openai/celest/lib/client.dart b/examples/openai/celest/lib/client.dart index 546780c3..33b5383b 100644 --- a/examples/openai/celest/lib/client.dart +++ b/examples/openai/celest/lib/client.dart @@ -15,12 +15,15 @@ import 'src/client/serializers.dart'; final Celest celest = Celest(); enum CelestEnvironment { - local; + local, + production; Uri get baseUri => switch (this) { local => kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:7781') - : Uri.parse('http://10.0.2.2:7781'), + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), + production => + Uri.parse('https://openai-example-xpsv-v76lntiq7q-wl.a.run.app'), }; } diff --git a/examples/openai/celest/lib/src/client/functions.dart b/examples/openai/celest/lib/src/client/functions.dart index bf2f5649..bc640b47 100644 --- a/examples/openai/celest/lib/src/client/functions.dart +++ b/examples/openai/celest/lib/src/client/functions.dart @@ -9,6 +9,7 @@ import 'dart:convert' as _$convert; import 'package:celest/celest.dart'; import 'package:celest_backend/models.dart' as _$models; import 'package:celest_core/src/exception/cloud_exception.dart'; +import 'package:celest_core/src/exception/serialization_exception.dart'; import '../../client.dart'; @@ -30,6 +31,9 @@ class CelestFunctionsOpenAi { case r'InternalServerException': throw Serializers.instance .deserialize($details); + case r'SerializationException': + throw Serializers.instance + .deserialize($details); case _: switch ($statusCode) { case 400: diff --git a/examples/openai/celest/lib/src/client/serializers.dart b/examples/openai/celest/lib/src/client/serializers.dart index 9f4a2275..0f551e66 100644 --- a/examples/openai/celest/lib/src/client/serializers.dart +++ b/examples/openai/celest/lib/src/client/serializers.dart @@ -4,6 +4,7 @@ import 'package:celest/celest.dart'; import 'package:celest_backend/models.dart' as _$models; import 'package:celest_core/src/exception/cloud_exception.dart'; +import 'package:celest_core/src/exception/serialization_exception.dart'; void initSerializers() { Serializers.instance @@ -33,4 +34,15 @@ void initSerializers() { return InternalServerException(($serialized[r'message'] as String)); }, )); + Serializers.instance + .put(Serializer.define>( + serialize: ($value) => { + r'message': $value.message, + r'offset': $value.offset, + r'source': $value.source, + }, + deserialize: ($serialized) { + return SerializationException(($serialized[r'message'] as String)); + }, + )); } diff --git a/examples/openai/celest/pubspec.lock b/examples/openai/celest/pubspec.lock index 9156f2af..2e34d9d2 100644 --- a/examples/openai/celest/pubspec.lock +++ b/examples/openai/celest/pubspec.lock @@ -53,10 +53,10 @@ packages: dependency: "direct main" description: name: celest_core - sha256: b9da8eb41f3b0ea5f76733dd74fede23f5430a57d8c8138963b28e99319bc0d0 + sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.2.1" chat_gpt_sdk: dependency: "direct main" description: diff --git a/examples/openai/celest/resources.dart b/examples/openai/celest/resources.dart index 8a77c198..5d045a7c 100644 --- a/examples/openai/celest/resources.dart +++ b/examples/openai/celest/resources.dart @@ -6,10 +6,16 @@ library; import 'package:celest/celest.dart'; +@Deprecated('Use `Apis` instead.') +typedef apis = Apis; + abstract final class Apis { static const openAi = CloudApi(name: r'open_ai'); } +@Deprecated('Use `Functions` instead.') +typedef functions = Functions; + abstract final class Functions { static const openAiAvailableModels = CloudFunction( api: r'open_ai', @@ -22,6 +28,9 @@ abstract final class Functions { ); } +@Deprecated('Use `Env` instead.') +typedef env = Env; + abstract final class Env { static const openAiToken = EnvironmentVariable(name: r'OPEN_AI_TOKEN'); } diff --git a/examples/openai/pubspec.lock b/examples/openai/pubspec.lock index da81dbd2..7a7f7e20 100644 --- a/examples/openai/pubspec.lock +++ b/examples/openai/pubspec.lock @@ -36,10 +36,10 @@ packages: dependency: transitive description: name: celest_core - sha256: b9da8eb41f3b0ea5f76733dd74fede23f5430a57d8c8138963b28e99319bc0d0 + sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.2.1" characters: dependency: transitive description: diff --git a/examples/todo/celest/lib/client.dart b/examples/todo/celest/lib/client.dart index 546780c3..1f1cfc16 100644 --- a/examples/todo/celest/lib/client.dart +++ b/examples/todo/celest/lib/client.dart @@ -19,8 +19,8 @@ enum CelestEnvironment { Uri get baseUri => switch (this) { local => kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:7781') - : Uri.parse('http://10.0.2.2:7781'), + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), }; } diff --git a/examples/todo/celest/pubspec.lock b/examples/todo/celest/pubspec.lock index d63a84c0..7794d9d6 100644 --- a/examples/todo/celest/pubspec.lock +++ b/examples/todo/celest/pubspec.lock @@ -53,10 +53,10 @@ packages: dependency: "direct main" description: name: celest_core - sha256: b9da8eb41f3b0ea5f76733dd74fede23f5430a57d8c8138963b28e99319bc0d0 + sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.2.1" chunked_stream: dependency: transitive description: diff --git a/examples/todo/celest/resources.dart b/examples/todo/celest/resources.dart index 842003ec..6050f6d0 100644 --- a/examples/todo/celest/resources.dart +++ b/examples/todo/celest/resources.dart @@ -6,10 +6,16 @@ library; import 'package:celest/celest.dart'; +@Deprecated('Use `Apis` instead.') +typedef apis = Apis; + abstract final class Apis { static const tasks = CloudApi(name: r'tasks'); } +@Deprecated('Use `Functions` instead.') +typedef functions = Functions; + abstract final class Functions { static const tasksAddTask = CloudFunction( api: r'tasks', diff --git a/examples/todo/pubspec.lock b/examples/todo/pubspec.lock index f424edb5..6f3043fa 100644 --- a/examples/todo/pubspec.lock +++ b/examples/todo/pubspec.lock @@ -36,10 +36,10 @@ packages: dependency: transitive description: name: celest_core - sha256: b9da8eb41f3b0ea5f76733dd74fede23f5430a57d8c8138963b28e99319bc0d0 + sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.2.1" characters: dependency: transitive description: diff --git a/packages/celest/example/celest/lib/client.dart b/packages/celest/example/celest/lib/client.dart index 546780c3..1f1cfc16 100644 --- a/packages/celest/example/celest/lib/client.dart +++ b/packages/celest/example/celest/lib/client.dart @@ -19,8 +19,8 @@ enum CelestEnvironment { Uri get baseUri => switch (this) { local => kIsWeb || !_$io.Platform.isAndroid - ? Uri.parse('http://localhost:7781') - : Uri.parse('http://10.0.2.2:7781'), + ? Uri.parse('http://localhost:7777') + : Uri.parse('http://10.0.2.2:7777'), }; } diff --git a/packages/celest/example/celest/resources.dart b/packages/celest/example/celest/resources.dart index 2925f5ca..9e08d4c3 100644 --- a/packages/celest/example/celest/resources.dart +++ b/packages/celest/example/celest/resources.dart @@ -6,10 +6,16 @@ library; import 'package:celest/celest.dart'; +@Deprecated('Use `Apis` instead.') +typedef apis = Apis; + abstract final class Apis { static const greeting = CloudApi(name: r'greeting'); } +@Deprecated('Use `Functions` instead.') +typedef functions = Functions; + abstract final class Functions { static const greetingSayHello = CloudFunction( api: r'greeting',