diff --git a/examples/gemini/celest/lib/client.dart b/examples/gemini/celest/lib/client.dart index 1f1cfc16..2903de69 100644 --- a/examples/gemini/celest/lib/client.dart +++ b/examples/gemini/celest/lib/client.dart @@ -6,6 +6,7 @@ library; // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:io' as _$io; +import 'package:celest_core/_internal.dart'; import 'package:celest_core/src/util/globals.dart'; import 'package:http/http.dart' as _$http; @@ -24,12 +25,16 @@ enum CelestEnvironment { }; } -class Celest { +class Celest with CelestBase { var _initialized = false; late CelestEnvironment _currentEnvironment; - late _$http.Client httpClient = _$http.Client(); + late final SecureStorage _secureStorage = SecureStorage(); + + @override + late _$http.Client httpClient = + CelestHttpClient(secureStorage: _secureStorage); late Uri _baseUri; @@ -46,6 +51,7 @@ class Celest { CelestEnvironment get currentEnvironment => _checkInitialized(() => _currentEnvironment); + @override Uri get baseUri => _checkInitialized(() => _baseUri); CelestFunctions get functions => _checkInitialized(() => _functions); diff --git a/examples/gemini/celest/lib/src/client/functions.dart b/examples/gemini/celest/lib/src/client/functions.dart index 2a117d0d..f2719a51 100644 --- a/examples/gemini/celest/lib/src/client/functions.dart +++ b/examples/gemini/celest/lib/src/client/functions.dart @@ -29,6 +29,8 @@ class CelestFunctionsGemini { switch ($code) { case r'BadRequestException': throw Serializers.instance.deserialize($details); + case r'UnauthorizedException': + throw Serializers.instance.deserialize($details); case r'InternalServerException': throw Serializers.instance .deserialize($details); diff --git a/examples/gemini/celest/lib/src/client/serializers.dart b/examples/gemini/celest/lib/src/client/serializers.dart index bc4b892d..79e49349 100644 --- a/examples/gemini/celest/lib/src/client/serializers.dart +++ b/examples/gemini/celest/lib/src/client/serializers.dart @@ -22,6 +22,14 @@ void initSerializers() { return InternalServerException(($serialized[r'message'] as String)); }, )); + Serializers.instance + .put(Serializer.define?>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return UnauthorizedException( + (($serialized?[r'message'] as String?)) ?? 'Unauthorized'); + }, + )); Serializers.instance .put(Serializer.define>( serialize: ($value) => { diff --git a/examples/gemini/celest/pubspec.lock b/examples/gemini/celest/pubspec.lock index 9ebca451..38d5ef43 100644 --- a/examples/gemini/celest/pubspec.lock +++ b/examples/gemini/celest/pubspec.lock @@ -41,22 +41,54 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + cedar: + dependency: transitive + description: + name: cedar + sha256: "08694362fce1f942d0f868ff8460931e2d32d9e568a1672ca98aa387cab248aa" + url: "https://pub.dev" + source: hosted + version: "0.1.0" celest: dependency: "direct main" description: name: celest - sha256: aa0d6bd43ed45f52d2f1a88b5dc00bf88439ab21f1d727c68938f54ccf3ba445 + sha256: bd1691ce2d75e394e2d2a7b41d8699ccc4e219d51846287cfe9ba7b6cd9a3989 + url: "https://pub.dev" + source: hosted + version: "0.3.1" + celest_auth: + dependency: transitive + description: + name: celest_auth + sha256: "63ad911778086b508c702a2ece3a56d7fea42a1e87c92c0031f213ccfabb25d6" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.3.0" celest_core: dependency: "direct main" description: name: celest_core - sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 + sha256: f4ce36b2f80a2717dd83302a735e1be16ca7ebcc5f145582b59e66176503f455 url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.3.1" chunked_stream: dependency: transitive description: @@ -81,6 +113,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" + corks_cedar: + dependency: transitive + description: + name: corks_cedar + sha256: "85296f9500ff5cf8ec135520fc28caaf2858af8a6da129d7caedaed869cb8a44" + url: "https://pub.dev" + source: hosted + version: "0.1.0" coverage: dependency: transitive description: @@ -97,6 +137,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" file: dependency: transitive description: @@ -105,6 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" frontend_server_client: dependency: transitive description: @@ -169,6 +225,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + jni: + dependency: transitive + description: + name: jni + sha256: "0d88790bdf7e298aa65a9094c62b58ea231169a2deb84f23defc7d7955885b43" + url: "https://pub.dev" + source: hosted + version: "0.7.2" js: dependency: transitive description: @@ -177,6 +241,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.1" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" lints: dependency: "direct dev" description: @@ -225,6 +297,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + os_detect: + dependency: transitive + description: + name: os_detect + sha256: faf3bcf39515e64da8ff76b2f2805b20a6ff47ae515393e535f8579ff91d6b7f + url: "https://pub.dev" + source: hosted + version: "2.0.1" package_config: dependency: transitive description: @@ -241,6 +321,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" pool: dependency: transitive description: @@ -249,6 +337,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" pub_semver: dependency: transitive description: @@ -337,6 +433,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -405,10 +509,10 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.5.1" web_socket_channel: dependency: transitive description: @@ -425,6 +529,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480" + url: "https://pub.dev" + source: hosted + version: "5.3.0" yaml: dependency: transitive description: @@ -435,3 +547,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/examples/gemini/celest/pubspec.yaml b/examples/gemini/celest/pubspec.yaml index c01c72d4..747fd3fe 100644 --- a/examples/gemini/celest/pubspec.yaml +++ b/examples/gemini/celest/pubspec.yaml @@ -6,8 +6,8 @@ environment: sdk: ^3.3.0 dependencies: - celest: ^0.2.0 - celest_core: ^0.2.0 + celest: ^0.3.0 + celest_core: ^0.3.0 google_generative_ai: ^0.2.0 http: ">=0.13.0 <2.0.0" diff --git a/examples/gemini/celest/resources.dart b/examples/gemini/celest/resources.dart index 7ab178df..8014ea1f 100644 --- a/examples/gemini/celest/resources.dart +++ b/examples/gemini/celest/resources.dart @@ -6,28 +6,6 @@ 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', - functionName: r'availableModels', - ); - - static const geminiGenerateContent = CloudFunction( - api: r'gemini', - functionName: r'generateContent', - ); -} - @Deprecated('Use `Env` instead.') typedef env = Env; diff --git a/examples/gemini/pubspec.lock b/examples/gemini/pubspec.lock index b5671d33..65a084a0 100644 --- a/examples/gemini/pubspec.lock +++ b/examples/gemini/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: @@ -17,14 +25,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + cedar: + dependency: transitive + description: + name: cedar + sha256: "08694362fce1f942d0f868ff8460931e2d32d9e568a1672ca98aa387cab248aa" + url: "https://pub.dev" + source: hosted + version: "0.1.0" celest: dependency: transitive description: name: celest - sha256: aa0d6bd43ed45f52d2f1a88b5dc00bf88439ab21f1d727c68938f54ccf3ba445 + sha256: bd1691ce2d75e394e2d2a7b41d8699ccc4e219d51846287cfe9ba7b6cd9a3989 + url: "https://pub.dev" + source: hosted + version: "0.3.1" + celest_auth: + dependency: transitive + description: + name: celest_auth + sha256: "63ad911778086b508c702a2ece3a56d7fea42a1e87c92c0031f213ccfabb25d6" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.3.0" celest_backend: dependency: "direct main" description: @@ -36,10 +76,10 @@ packages: dependency: transitive description: name: celest_core - sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 + sha256: f4ce36b2f80a2717dd83302a735e1be16ca7ebcc5f145582b59e66176503f455 url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.3.1" characters: dependency: transitive description: @@ -72,6 +112,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + corks_cedar: + dependency: transitive + description: + name: corks_cedar + sha256: "85296f9500ff5cf8ec135520fc28caaf2858af8a6da129d7caedaed869cb8a44" + url: "https://pub.dev" + source: hosted + version: "0.1.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" cupertino_icons: dependency: "direct main" description: @@ -88,6 +144,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -138,6 +210,22 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + jni: + dependency: transitive + description: + name: jni + sha256: "0d88790bdf7e298aa65a9094c62b58ea231169a2deb84f23defc7d7955885b43" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" leak_tracker: dependency: transitive description: @@ -170,6 +258,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -194,6 +290,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + os_detect: + dependency: transitive + description: + name: os_detect + sha256: faf3bcf39515e64da8ff76b2f2805b20a6ff47ae515393e535f8579ff91d6b7f + url: "https://pub.dev" + source: hosted + version: "2.0.1" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -202,6 +314,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" shelf: dependency: transitive description: @@ -247,6 +375,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -299,9 +435,18 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "5.3.0" sdks: dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/examples/openai/celest/lib/client.dart b/examples/openai/celest/lib/client.dart index 33b5383b..74bcca10 100644 --- a/examples/openai/celest/lib/client.dart +++ b/examples/openai/celest/lib/client.dart @@ -6,6 +6,7 @@ library; // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:io' as _$io; +import 'package:celest_core/_internal.dart'; import 'package:celest_core/src/util/globals.dart'; import 'package:http/http.dart' as _$http; @@ -23,16 +24,20 @@ enum CelestEnvironment { ? 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'), + Uri.parse('https://openai-example-usok-v76lntiq7q-wl.a.run.app'), }; } -class Celest { +class Celest with CelestBase { var _initialized = false; late CelestEnvironment _currentEnvironment; - late _$http.Client httpClient = _$http.Client(); + late final SecureStorage _secureStorage = SecureStorage(); + + @override + late _$http.Client httpClient = + CelestHttpClient(secureStorage: _secureStorage); late Uri _baseUri; @@ -49,6 +54,7 @@ class Celest { CelestEnvironment get currentEnvironment => _checkInitialized(() => _currentEnvironment); + @override Uri get baseUri => _checkInitialized(() => _baseUri); CelestFunctions get functions => _checkInitialized(() => _functions); diff --git a/examples/openai/celest/lib/src/client/functions.dart b/examples/openai/celest/lib/src/client/functions.dart index bc640b47..3d21e0cf 100644 --- a/examples/openai/celest/lib/src/client/functions.dart +++ b/examples/openai/celest/lib/src/client/functions.dart @@ -28,6 +28,8 @@ class CelestFunctionsOpenAi { switch ($code) { case r'BadRequestException': throw Serializers.instance.deserialize($details); + case r'UnauthorizedException': + throw Serializers.instance.deserialize($details); case r'InternalServerException': throw Serializers.instance .deserialize($details); diff --git a/examples/openai/celest/lib/src/client/serializers.dart b/examples/openai/celest/lib/src/client/serializers.dart index 0f551e66..b9483fc2 100644 --- a/examples/openai/celest/lib/src/client/serializers.dart +++ b/examples/openai/celest/lib/src/client/serializers.dart @@ -34,6 +34,14 @@ void initSerializers() { return InternalServerException(($serialized[r'message'] as String)); }, )); + Serializers.instance + .put(Serializer.define?>( + serialize: ($value) => {r'message': $value.message}, + deserialize: ($serialized) { + return UnauthorizedException( + (($serialized?[r'message'] as String?)) ?? 'Unauthorized'); + }, + )); Serializers.instance .put(Serializer.define>( serialize: ($value) => { diff --git a/examples/openai/celest/pubspec.lock b/examples/openai/celest/pubspec.lock index 2e34d9d2..4bf2af77 100644 --- a/examples/openai/celest/pubspec.lock +++ b/examples/openai/celest/pubspec.lock @@ -41,22 +41,54 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + cedar: + dependency: transitive + description: + name: cedar + sha256: "08694362fce1f942d0f868ff8460931e2d32d9e568a1672ca98aa387cab248aa" + url: "https://pub.dev" + source: hosted + version: "0.1.0" celest: dependency: "direct main" description: name: celest - sha256: aa0d6bd43ed45f52d2f1a88b5dc00bf88439ab21f1d727c68938f54ccf3ba445 + sha256: bd1691ce2d75e394e2d2a7b41d8699ccc4e219d51846287cfe9ba7b6cd9a3989 + url: "https://pub.dev" + source: hosted + version: "0.3.1" + celest_auth: + dependency: transitive + description: + name: celest_auth + sha256: "63ad911778086b508c702a2ece3a56d7fea42a1e87c92c0031f213ccfabb25d6" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.3.0" celest_core: dependency: "direct main" description: name: celest_core - sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 + sha256: f4ce36b2f80a2717dd83302a735e1be16ca7ebcc5f145582b59e66176503f455 url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.3.1" chat_gpt_sdk: dependency: "direct main" description: @@ -89,6 +121,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" + corks_cedar: + dependency: transitive + description: + name: corks_cedar + sha256: "85296f9500ff5cf8ec135520fc28caaf2858af8a6da129d7caedaed869cb8a44" + url: "https://pub.dev" + source: hosted + version: "0.1.0" coverage: dependency: transitive description: @@ -113,6 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.4.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" file: dependency: transitive description: @@ -121,6 +169,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" frontend_server_client: dependency: transitive description: @@ -177,6 +233,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + jni: + dependency: transitive + description: + name: jni + sha256: "0d88790bdf7e298aa65a9094c62b58ea231169a2deb84f23defc7d7955885b43" + url: "https://pub.dev" + source: hosted + version: "0.7.2" js: dependency: transitive description: @@ -185,6 +249,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.1" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" lints: dependency: "direct dev" description: @@ -233,6 +305,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + os_detect: + dependency: transitive + description: + name: os_detect + sha256: faf3bcf39515e64da8ff76b2f2805b20a6ff47ae515393e535f8579ff91d6b7f + url: "https://pub.dev" + source: hosted + version: "2.0.1" package_config: dependency: transitive description: @@ -249,6 +329,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" pool: dependency: transitive description: @@ -257,6 +345,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" pub_semver: dependency: transitive description: @@ -345,6 +441,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -413,10 +517,10 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.5.1" web_socket_channel: dependency: transitive description: @@ -433,6 +537,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480" + url: "https://pub.dev" + source: hosted + version: "5.3.0" yaml: dependency: transitive description: @@ -443,3 +555,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/examples/openai/celest/pubspec.yaml b/examples/openai/celest/pubspec.yaml index 740aa8bf..343ded54 100644 --- a/examples/openai/celest/pubspec.yaml +++ b/examples/openai/celest/pubspec.yaml @@ -6,8 +6,8 @@ environment: sdk: ^3.3.0 dependencies: - celest: ^0.2.0 - celest_core: ^0.2.0 + celest: ^0.3.0 + celest_core: ^0.3.0 chat_gpt_sdk: ^2.2.8 http: ">=0.13.0 <2.0.0" diff --git a/examples/openai/celest/resources.dart b/examples/openai/celest/resources.dart index 5d045a7c..fb457dd2 100644 --- a/examples/openai/celest/resources.dart +++ b/examples/openai/celest/resources.dart @@ -6,28 +6,6 @@ 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', - functionName: r'availableModels', - ); - - static const openAiOpenAiRequest = CloudFunction( - api: r'open_ai', - functionName: r'openAIRequest', - ); -} - @Deprecated('Use `Env` instead.') typedef env = Env; diff --git a/examples/openai/pubspec.lock b/examples/openai/pubspec.lock index 7a7f7e20..aa4f8891 100644 --- a/examples/openai/pubspec.lock +++ b/examples/openai/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: @@ -17,14 +25,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + cedar: + dependency: transitive + description: + name: cedar + sha256: "08694362fce1f942d0f868ff8460931e2d32d9e568a1672ca98aa387cab248aa" + url: "https://pub.dev" + source: hosted + version: "0.1.0" celest: dependency: transitive description: name: celest - sha256: aa0d6bd43ed45f52d2f1a88b5dc00bf88439ab21f1d727c68938f54ccf3ba445 + sha256: bd1691ce2d75e394e2d2a7b41d8699ccc4e219d51846287cfe9ba7b6cd9a3989 + url: "https://pub.dev" + source: hosted + version: "0.3.1" + celest_auth: + dependency: transitive + description: + name: celest_auth + sha256: "63ad911778086b508c702a2ece3a56d7fea42a1e87c92c0031f213ccfabb25d6" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.3.0" celest_backend: dependency: "direct main" description: @@ -36,10 +76,10 @@ packages: dependency: transitive description: name: celest_core - sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 + sha256: f4ce36b2f80a2717dd83302a735e1be16ca7ebcc5f145582b59e66176503f455 url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.3.1" characters: dependency: transitive description: @@ -80,6 +120,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + corks_cedar: + dependency: transitive + description: + name: corks_cedar + sha256: "85296f9500ff5cf8ec135520fc28caaf2858af8a6da129d7caedaed869cb8a44" + url: "https://pub.dev" + source: hosted + version: "0.1.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" cupertino_icons: dependency: "direct main" description: @@ -104,6 +160,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -146,6 +218,22 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + jni: + dependency: transitive + description: + name: jni + sha256: "0d88790bdf7e298aa65a9094c62b58ea231169a2deb84f23defc7d7955885b43" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" leak_tracker: dependency: transitive description: @@ -182,10 +270,18 @@ packages: dependency: "direct main" description: name: logger - sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac" + sha256: b3ff55aeb08d9d8901b767650285872cb1bb8f508373b3e348d60268b0c7f770 url: "https://pub.dev" source: hosted - version: "2.0.2+1" + version: "2.1.0" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -210,6 +306,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + os_detect: + dependency: transitive + description: + name: os_detect + sha256: faf3bcf39515e64da8ff76b2f2805b20a6ff47ae515393e535f8579ff91d6b7f + url: "https://pub.dev" + source: hosted + version: "2.0.1" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -218,6 +330,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" shelf: dependency: transitive description: @@ -263,6 +391,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -315,9 +451,18 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "5.3.0" sdks: dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/examples/todo/celest/lib/client.dart b/examples/todo/celest/lib/client.dart index 1f1cfc16..2903de69 100644 --- a/examples/todo/celest/lib/client.dart +++ b/examples/todo/celest/lib/client.dart @@ -6,6 +6,7 @@ library; // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:io' as _$io; +import 'package:celest_core/_internal.dart'; import 'package:celest_core/src/util/globals.dart'; import 'package:http/http.dart' as _$http; @@ -24,12 +25,16 @@ enum CelestEnvironment { }; } -class Celest { +class Celest with CelestBase { var _initialized = false; late CelestEnvironment _currentEnvironment; - late _$http.Client httpClient = _$http.Client(); + late final SecureStorage _secureStorage = SecureStorage(); + + @override + late _$http.Client httpClient = + CelestHttpClient(secureStorage: _secureStorage); late Uri _baseUri; @@ -46,6 +51,7 @@ class Celest { CelestEnvironment get currentEnvironment => _checkInitialized(() => _currentEnvironment); + @override Uri get baseUri => _checkInitialized(() => _baseUri); CelestFunctions get functions => _checkInitialized(() => _functions); diff --git a/examples/todo/celest/pubspec.lock b/examples/todo/celest/pubspec.lock index 7794d9d6..8c0ada9b 100644 --- a/examples/todo/celest/pubspec.lock +++ b/examples/todo/celest/pubspec.lock @@ -41,22 +41,54 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + cedar: + dependency: transitive + description: + name: cedar + sha256: "08694362fce1f942d0f868ff8460931e2d32d9e568a1672ca98aa387cab248aa" + url: "https://pub.dev" + source: hosted + version: "0.1.0" celest: dependency: "direct main" description: name: celest - sha256: aa0d6bd43ed45f52d2f1a88b5dc00bf88439ab21f1d727c68938f54ccf3ba445 + sha256: bd1691ce2d75e394e2d2a7b41d8699ccc4e219d51846287cfe9ba7b6cd9a3989 url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.3.1" + celest_auth: + dependency: transitive + description: + name: celest_auth + sha256: "63ad911778086b508c702a2ece3a56d7fea42a1e87c92c0031f213ccfabb25d6" + url: "https://pub.dev" + source: hosted + version: "0.3.0" celest_core: dependency: "direct main" description: name: celest_core - sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 + sha256: f4ce36b2f80a2717dd83302a735e1be16ca7ebcc5f145582b59e66176503f455 url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.3.1" chunked_stream: dependency: transitive description: @@ -81,6 +113,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" + corks_cedar: + dependency: transitive + description: + name: corks_cedar + sha256: "85296f9500ff5cf8ec135520fc28caaf2858af8a6da129d7caedaed869cb8a44" + url: "https://pub.dev" + source: hosted + version: "0.1.0" coverage: dependency: transitive description: @@ -97,6 +137,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" file: dependency: transitive description: @@ -169,6 +217,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + jni: + dependency: transitive + description: + name: jni + sha256: "0d88790bdf7e298aa65a9094c62b58ea231169a2deb84f23defc7d7955885b43" + url: "https://pub.dev" + source: hosted + version: "0.7.2" js: dependency: transitive description: @@ -177,6 +233,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.1" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" lints: dependency: "direct dev" description: @@ -225,6 +289,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + os_detect: + dependency: transitive + description: + name: os_detect + sha256: faf3bcf39515e64da8ff76b2f2805b20a6ff47ae515393e535f8579ff91d6b7f + url: "https://pub.dev" + source: hosted + version: "2.0.1" package_config: dependency: transitive description: @@ -241,6 +313,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" pool: dependency: transitive description: @@ -249,6 +329,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" pub_semver: dependency: transitive description: @@ -345,6 +433,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -421,10 +517,10 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.5.1" web_socket_channel: dependency: transitive description: @@ -441,6 +537,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480" + url: "https://pub.dev" + source: hosted + version: "5.3.0" yaml: dependency: transitive description: @@ -451,3 +555,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/examples/todo/celest/pubspec.yaml b/examples/todo/celest/pubspec.yaml index a2f16401..487ae4ba 100644 --- a/examples/todo/celest/pubspec.yaml +++ b/examples/todo/celest/pubspec.yaml @@ -6,8 +6,8 @@ environment: sdk: ^3.3.0 dependencies: - celest: ^0.2.0 - celest_core: ^0.2.0 + celest: ^0.3.0 + celest_core: ^0.3.0 http: ">=0.13.0 <2.0.0" uuid: ^4.3.3 diff --git a/examples/todo/celest/resources.dart b/examples/todo/celest/resources.dart index 6050f6d0..ffc4fd72 100644 --- a/examples/todo/celest/resources.dart +++ b/examples/todo/celest/resources.dart @@ -3,42 +3,3 @@ // ignore_for_file: type=lint, unused_local_variable, unnecessary_cast, unnecessary_import 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', - functionName: r'addTask', - ); - - static const tasksDeleteTask = CloudFunction( - api: r'tasks', - functionName: r'deleteTask', - ); - - static const tasksListAllTasks = CloudFunction( - api: r'tasks', - functionName: r'listAllTasks', - ); - - static const tasksMarkAsCompleted = CloudFunction( - api: r'tasks', - functionName: r'markAsCompleted', - ); - - static const tasksMarkAsIncomplete = CloudFunction( - api: r'tasks', - functionName: r'markAsIncomplete', - ); -} diff --git a/examples/todo/ios/Flutter/Debug.xcconfig b/examples/todo/ios/Flutter/Debug.xcconfig index 592ceee8..ec97fc6f 100644 --- a/examples/todo/ios/Flutter/Debug.xcconfig +++ b/examples/todo/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/examples/todo/ios/Flutter/Release.xcconfig b/examples/todo/ios/Flutter/Release.xcconfig index 592ceee8..c4855bfe 100644 --- a/examples/todo/ios/Flutter/Release.xcconfig +++ b/examples/todo/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/examples/todo/ios/Podfile b/examples/todo/ios/Podfile new file mode 100644 index 00000000..d97f17e2 --- /dev/null +++ b/examples/todo/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/examples/todo/linux/flutter/generated_plugins.cmake b/examples/todo/linux/flutter/generated_plugins.cmake index 2e1de87a..be1ee3e5 100644 --- a/examples/todo/linux/flutter/generated_plugins.cmake +++ b/examples/todo/linux/flutter/generated_plugins.cmake @@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/examples/todo/macos/Flutter/Flutter-Debug.xcconfig b/examples/todo/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b6..4b81f9b2 100644 --- a/examples/todo/macos/Flutter/Flutter-Debug.xcconfig +++ b/examples/todo/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/examples/todo/macos/Flutter/Flutter-Release.xcconfig b/examples/todo/macos/Flutter/Flutter-Release.xcconfig index c2efd0b6..5caa9d15 100644 --- a/examples/todo/macos/Flutter/Flutter-Release.xcconfig +++ b/examples/todo/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/examples/todo/macos/Podfile b/examples/todo/macos/Podfile new file mode 100644 index 00000000..c795730d --- /dev/null +++ b/examples/todo/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/examples/todo/pubspec.lock b/examples/todo/pubspec.lock index 6f3043fa..e50ec12f 100644 --- a/examples/todo/pubspec.lock +++ b/examples/todo/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" async: dependency: transitive description: @@ -17,14 +25,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + cedar: + dependency: transitive + description: + name: cedar + sha256: "08694362fce1f942d0f868ff8460931e2d32d9e568a1672ca98aa387cab248aa" + url: "https://pub.dev" + source: hosted + version: "0.1.0" celest: dependency: transitive description: name: celest - sha256: aa0d6bd43ed45f52d2f1a88b5dc00bf88439ab21f1d727c68938f54ccf3ba445 + sha256: bd1691ce2d75e394e2d2a7b41d8699ccc4e219d51846287cfe9ba7b6cd9a3989 + url: "https://pub.dev" + source: hosted + version: "0.3.1" + celest_auth: + dependency: transitive + description: + name: celest_auth + sha256: "63ad911778086b508c702a2ece3a56d7fea42a1e87c92c0031f213ccfabb25d6" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.3.0" celest_backend: dependency: "direct main" description: @@ -36,10 +76,10 @@ packages: dependency: transitive description: name: celest_core - sha256: c9ae3214327494291c2bbbc5ac7b5b63be03484e9d63fd06d8fe9ad938256963 + sha256: f4ce36b2f80a2717dd83302a735e1be16ca7ebcc5f145582b59e66176503f455 url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "0.3.1" characters: dependency: transitive description: @@ -72,6 +112,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + corks_cedar: + dependency: transitive + description: + name: corks_cedar + sha256: "85296f9500ff5cf8ec135520fc28caaf2858af8a6da129d7caedaed869cb8a44" + url: "https://pub.dev" + source: hosted + version: "0.1.0" crypto: dependency: transitive description: @@ -88,6 +136,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" fixnum: dependency: transitive description: @@ -138,6 +194,22 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + jni: + dependency: transitive + description: + name: jni + sha256: "0d88790bdf7e298aa65a9094c62b58ea231169a2deb84f23defc7d7955885b43" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" leak_tracker: dependency: transitive description: @@ -170,6 +242,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -194,6 +274,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + os_detect: + dependency: transitive + description: + name: os_detect + sha256: faf3bcf39515e64da8ff76b2f2805b20a6ff47ae515393e535f8579ff91d6b7f + url: "https://pub.dev" + source: hosted + version: "2.0.1" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -202,6 +298,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" shelf: dependency: transitive description: @@ -255,6 +367,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -315,9 +435,18 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + win32: + dependency: transitive + description: + name: win32 + sha256: "8cb58b45c47dcb42ab3651533626161d6b67a2921917d8d429791f76972b3480" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "5.3.0" sdks: dart: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" diff --git a/examples/todo/windows/flutter/generated_plugins.cmake b/examples/todo/windows/flutter/generated_plugins.cmake index b93c4c30..3ad69c61 100644 --- a/examples/todo/windows/flutter/generated_plugins.cmake +++ b/examples/todo/windows/flutter/generated_plugins.cmake @@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/packages/celest/CHANGELOG.md b/packages/celest/CHANGELOG.md index 6d7fa6ba..db4bdca3 100644 --- a/packages/celest/CHANGELOG.md +++ b/packages/celest/CHANGELOG.md @@ -1,6 +1,10 @@ -## 0.3.0-dev.1 +## 0.3.1 -- Initial release of Celest Auth +- Makes request context not specific to Celest + +## 0.3.0 + +- Initial release of Celest Auth with email OTP support ## 0.2.0 diff --git a/packages/celest/lib/src/runtime/serve.dart b/packages/celest/lib/src/runtime/serve.dart index 8b84b29e..0ecb38f0 100644 --- a/packages/celest/lib/src/runtime/serve.dart +++ b/packages/celest/lib/src/runtime/serve.dart @@ -57,7 +57,7 @@ abstract base class CloudFunctionTarget { init(); } - static const _contextHeaderPrefix = 'X-Celest-Context-'; + static const _contextHeaderPrefix = 'X-Context-'; static final _contextHeaderMatcher = RegExp( _contextHeaderPrefix, caseSensitive: false, @@ -65,12 +65,16 @@ abstract base class CloudFunctionTarget { Future _handler(Request request) async { final bodyJson = await request.decodeJson(); + final context = {}; + request.headers.forEach((key, value) { + key = key.toLowerCase(); + if (key.startsWith(_contextHeaderMatcher)) { + context[key.substring(_contextHeaderPrefix.length)] = value; + } + }); final response = await runZoned( () => handle({ - for (final MapEntry(:key, :value) in request.headers.entries) - if (key.startsWith(_contextHeaderMatcher)) - '\$${key.substring(_contextHeaderPrefix.length).toLowerCase()}': - value, + r'$context': context, ...bodyJson, }), zoneSpecification: ZoneSpecification( diff --git a/packages/celest/pubspec.yaml b/packages/celest/pubspec.yaml index 25646ea4..305f4760 100644 --- a/packages/celest/pubspec.yaml +++ b/packages/celest/pubspec.yaml @@ -1,6 +1,6 @@ name: celest description: The Flutter cloud platform. Celest enables you to build your entire backend in Dart. -version: 0.3.0-dev.1 +version: 0.3.1 homepage: https://celest.dev repository: https://github.com/celest-dev/celest/tree/main/packages/celest @@ -9,8 +9,8 @@ environment: dependencies: async: ^2.11.0 - celest_auth: ^0.3.0-dev.1 - celest_core: ^0.3.0-dev.1 + celest_auth: ^0.3.0 + celest_core: ^0.3.0 chunked_stream: ^1.4.2 meta: ^1.9.0 shelf: ^1.4.1 diff --git a/packages/celest_auth/CHANGELOG.md b/packages/celest_auth/CHANGELOG.md index eef20f21..338fca0c 100644 --- a/packages/celest_auth/CHANGELOG.md +++ b/packages/celest_auth/CHANGELOG.md @@ -1,7 +1,7 @@ -## 0.3.0-dev.2 +## 0.3.1 -- Clear browser cookies on `signOut` +- Use required parameters throughout for better consistency -## 0.3.0-dev.1 +## 0.3.0 - Initial version. diff --git a/packages/celest_auth/example/celest/pubspec.yaml b/packages/celest_auth/example/celest/pubspec.yaml index 3a2a0972..d59a1407 100644 --- a/packages/celest_auth/example/celest/pubspec.yaml +++ b/packages/celest_auth/example/celest/pubspec.yaml @@ -6,8 +6,8 @@ environment: sdk: ^3.3.0 dependencies: - celest: ^0.3.0-0 - celest_core: ^0.3.0-0 + celest: ^0.3.0 + celest_core: ^0.3.0 http: ">=0.13.0 <2.0.0" dependency_overrides: diff --git a/packages/celest_auth/example/lib/main.dart b/packages/celest_auth/example/lib/main.dart index 4a37d685..9462fd71 100644 --- a/packages/celest_auth/example/lib/main.dart +++ b/packages/celest_auth/example/lib/main.dart @@ -93,7 +93,7 @@ class _MainAppState extends State { const SizedBox(height: 16), TextButton( onPressed: () => state.verify( - _otpController.text, + otpCode: _otpController.text, ), child: const Text('Verify OTP'), ), diff --git a/packages/celest_auth/lib/src/auth_impl.dart b/packages/celest_auth/lib/src/auth_impl.dart index eb0cb8db..d841760e 100644 --- a/packages/celest_auth/lib/src/auth_impl.dart +++ b/packages/celest_auth/lib/src/auth_impl.dart @@ -41,7 +41,7 @@ final class AuthImpl implements Auth { AuthState initialState; try { final user = await protocol.userInfo(); - initialState = Authenticated(user); + initialState = Authenticated(user: user); _authStateController.add(initialState); } on UnauthorizedException { initialState = const Unauthenticated(); diff --git a/packages/celest_auth/lib/src/flows/email_flow.dart b/packages/celest_auth/lib/src/flows/email_flow.dart index d688e6c1..7386bb73 100644 --- a/packages/celest_auth/lib/src/flows/email_flow.dart +++ b/packages/celest_auth/lib/src/flows/email_flow.dart @@ -55,7 +55,7 @@ final class EmailFlow implements AuthFlow { ); _hub.secureStorage.write('cork', user.cork); _hub.localStorage.write('userId', user.user.userId); - return Authenticated(user.user); + return Authenticated(user: user.user); }); } @@ -80,7 +80,7 @@ final class _EmailNeedsVerification extends EmailNeedsVerification { } @override - Future verify(String otpCode) async { + Future verify({required String otpCode}) async { final authenticated = await _flow._verifyOtp(email: email, otp: otpCode); return authenticated.user; } diff --git a/packages/celest_auth/lib/src/state/auth_state.dart b/packages/celest_auth/lib/src/state/auth_state.dart index 42e1b077..ba0d621d 100644 --- a/packages/celest_auth/lib/src/state/auth_state.dart +++ b/packages/celest_auth/lib/src/state/auth_state.dart @@ -28,12 +28,14 @@ abstract class EmailNeedsVerification extends AuthFlowInProgress { final String email; Future resend(); - Future verify(String otpCode); + Future verify({required String otpCode}); } /// The [user] is authenticated and their identity has been verified. final class Authenticated extends AuthState { - const Authenticated(this.user); + const Authenticated({ + required this.user, + }); final User user; } diff --git a/packages/celest_auth/pubspec.yaml b/packages/celest_auth/pubspec.yaml index dbb2918f..bd772aa1 100644 --- a/packages/celest_auth/pubspec.yaml +++ b/packages/celest_auth/pubspec.yaml @@ -1,6 +1,6 @@ name: celest_auth description: The Auth runtime and client library for Celest, the Flutter cloud platform. -version: 0.3.0-dev.2 +version: 0.3.1 homepage: https://celest.dev repository: https://github.com/celest-dev/celest/tree/main/packages/celest_auth @@ -12,7 +12,7 @@ dependencies: built_collection: ^5.1.1 built_value: ^8.9.1 cedar: ^0.1.0 - celest_core: ^0.3.0-dev.2 + celest_core: ^0.3.0 chunked_stream: ^1.4.2 corks_cedar: ^0.1.0 ffi: ^2.1.2 diff --git a/packages/celest_core/CHANGELOG.md b/packages/celest_core/CHANGELOG.md index 0dde39b5..ba14c536 100644 --- a/packages/celest_core/CHANGELOG.md +++ b/packages/celest_core/CHANGELOG.md @@ -1,8 +1,8 @@ -## 0.3.0-dev.2 +## 0.3.1 -- Add `signOut` method to `AuthProtocol` for clearing browser cookies +- Fix secure storage issues on Android and Linux -## 0.3.0-dev.1 +## 0.3.0 - Adds `SecureStorage` interface for storage of sensitive data in the platform keychain - Adds core Auth types and interfaces diff --git a/packages/celest_core/lib/src/http/celest_http_client.dart b/packages/celest_core/lib/src/http/celest_http_client.dart index c8c33d66..f9769da7 100644 --- a/packages/celest_core/lib/src/http/celest_http_client.dart +++ b/packages/celest_core/lib/src/http/celest_http_client.dart @@ -1,10 +1,6 @@ -import 'dart:isolate'; - import 'package:celest_core/src/http/http_client.vm.dart' if (dart.library.js_interop) 'package:celest_core/src/http/http_client.web.dart'; import 'package:celest_core/src/storage/secure/secure_storage.dart'; -import 'package:celest_core/src/storage/storage.dart'; -import 'package:celest_core/src/util/globals.dart'; import 'package:http/http.dart' as http; final class CelestHttpClient extends http.BaseClient { @@ -21,7 +17,7 @@ final class CelestHttpClient extends http.BaseClient { @override Future send(http.BaseRequest request) async { - final cork = await _readStorage(_secureStorage, 'cork'); + final cork = _secureStorage.read('cork'); if (cork != null) { request.headers['authorization'] = 'Bearer $cork'; } @@ -35,10 +31,3 @@ final class CelestHttpClient extends http.BaseClient { } } } - -Future _readStorage(Storage storage, String key) async { - if (kIsWeb) { - return null; - } - return Isolate.run(() => storage.read(key)); -} diff --git a/packages/celest_core/pubspec.yaml b/packages/celest_core/pubspec.yaml index b35d4c3c..12ddcc06 100644 --- a/packages/celest_core/pubspec.yaml +++ b/packages/celest_core/pubspec.yaml @@ -1,6 +1,6 @@ name: celest_core description: Celest types and utilities shared between the client and the cloud. -version: 0.3.0-dev.2 +version: 0.3.1 homepage: https://celest.dev repository: https://github.com/celest-dev/celest/tree/main/packages/celest_core