Skip to content

Commit

Permalink
Merge branch 'main' into feat/celest_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
dnys1 committed Mar 6, 2024
2 parents 4bfa8cf + d6cbcb9 commit 1ede4a9
Show file tree
Hide file tree
Showing 177 changed files with 14,028 additions and 52 deletions.
57 changes: 57 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## GITATTRIBUTES
#
# Details per file setting:
# text These files should be normalized (i.e. convert CRLF to LF).
# binary These files are binary and should be left untouched.
#
# Reference: https://git-scm.com/docs/gitattributes
# GitHub Linguist: https://github.com/github-linguist/linguist/blob/master/docs/overrides.md
######################################################################

# Auto detect text files and perform LF normalization
* text=auto

# Always perform LF normalization
*.dart text
*.gradle text
*.go text
*.html text
*.java text
*.js text
*.json text linguist-language=JSON-with-Comments
*.md text
*.sh text
*.ts text
*.txt text
*.xml text
*.yaml text

# Make sure that these Windows files always have CRLF line endings at checkout
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.rc text eol=crlf
*.sln text eol=crlf
*.props text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
# Including templates
*.sln.tmpl text eol=crlf
*.props.tmpl text eol=crlf
*.vcxproj.tmpl text eol=crlf

## Platform files generated by Flutter during `flutter create`
**/example/android/** linguist-generated
**/example/ios/** linguist-generated
**/example/linux/** linguist-generated
**/example/macos/** linguist-generated
**/example/windows/** linguist-generated
## Exclude flutter generated web files without excluding web files from
## non-flutter dart example apps
**/example/web/icons/** linguist-generated
**/example/web/*.json linguist-generated
**/example/web/*.png linguist-generated

## Generated Dart files
**/*.g.dart linguist-generated
**/*.ffi.dart linguist-generated
2 changes: 1 addition & 1 deletion .github/workflows/celest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Git Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
- name: Setup Flutter
uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225 # 2.12.0
uses: subosito/flutter-action@62f096cacda5168a3bd7b95793373be14fa4fbaf # 2.13.0
with:
channel: stable
cache: true
Expand Down
71 changes: 68 additions & 3 deletions .github/workflows/celest_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,79 @@ jobs:
steps:
- name: Git Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
- name: Setup Dart
uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 # 1.6.2
- name: Setup Flutter
uses: subosito/flutter-action@62f096cacda5168a3bd7b95793373be14fa4fbaf # 2.13.0
with:
cache: true
- name: Get Packages
working-directory: packages/celest_core
run: dart pub get
- name: Analyze
working-directory: packages/celest_core
run: dart analyze --fatal-infos --fatal-warnings
run: dart analyze
- name: Format
working-directory: packages/celest_core
run: dart format --set-exit-if-changed .
test_darwin:
needs: analyze_and_format
runs-on: macos-latest-xlarge
timeout-minutes: 20
steps:
- name: Git Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
- name: Setup Flutter
uses: subosito/flutter-action@62f096cacda5168a3bd7b95793373be14fa4fbaf # 2.13.0
with:
cache: true
- name: Get Packages
working-directory: packages/celest_core
run: dart pub get
- name: Test
working-directory: packages/celest_core
run: dart test
- name: Get Packages (Example)
working-directory: packages/celest_core/example
run: flutter pub get
- name: Setup iOS Simulator
run: |
RUNTIME=$(xcrun simctl list runtimes | grep 'iOS 17' | tail -n 1 | cut -d' ' -f 7)
echo "Using runtime: $RUNTIME"
xcrun simctl create ios 'iPhone 15 Pro Max' $RUNTIME
echo "Booting simulator"
xcrun simctl boot ios
echo "Booted simulator"
- name: Test (iOS)
working-directory: packages/celest_core/example
run: flutter test -d ios integration_test/secure_storage_test.dart
- name: Test (macOS)
working-directory: packages/celest_core/example
run: flutter test -d macos integration_test/secure_storage_test.dart
test_android:
needs: analyze_and_format
runs-on:
group: public
labels: linux
timeout-minutes: 15
steps:
- name: Git Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
- name: Setup Flutter
uses: subosito/flutter-action@62f096cacda5168a3bd7b95793373be14fa4fbaf # 2.13.0
with:
cache: true
- name: Get Packages
working-directory: packages/celest_core/example
run: flutter pub get
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Test (Android)
uses: ReactiveCircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 # 2.30.1
with:
# Matches `package:jni` compileSdkVersion
# https://github.com/dart-lang/native/blob/001910c9f40d637cb25c19bb500fb89cebdf7450/pkgs/jni/android/build.gradle#L57C23-L57C25
api-level: 31
arch: x86_64
script: cd packages/celest_core/example && flutter test -d emulator integration_test/secure_storage_test.dart
4 changes: 2 additions & 2 deletions examples/gemini/celest/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
};
}

Expand Down
9 changes: 9 additions & 0 deletions examples/gemini/celest/resources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
}
9 changes: 6 additions & 3 deletions examples/openai/celest/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
};
}

Expand Down
4 changes: 4 additions & 0 deletions examples/openai/celest/lib/src/client/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -30,6 +31,9 @@ class CelestFunctionsOpenAi {
case r'InternalServerException':
throw Serializers.instance
.deserialize<InternalServerException>($details);
case r'SerializationException':
throw Serializers.instance
.deserialize<SerializationException>($details);
case _:
switch ($statusCode) {
case 400:
Expand Down
12 changes: 12 additions & 0 deletions examples/openai/celest/lib/src/client/serializers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -33,4 +34,15 @@ void initSerializers() {
return InternalServerException(($serialized[r'message'] as String));
},
));
Serializers.instance
.put(Serializer.define<SerializationException, Map<String, Object?>>(
serialize: ($value) => {
r'message': $value.message,
r'offset': $value.offset,
r'source': $value.source,
},
deserialize: ($serialized) {
return SerializationException(($serialized[r'message'] as String));
},
));
}
4 changes: 2 additions & 2 deletions examples/openai/celest/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions examples/openai/celest/resources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
}
4 changes: 2 additions & 2 deletions examples/openai/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions examples/todo/celest/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
};
}

Expand Down
4 changes: 2 additions & 2 deletions examples/todo/celest/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions examples/todo/celest/resources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions examples/todo/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions packages/celest/example/celest/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
};
}

Expand Down
6 changes: 6 additions & 0 deletions packages/celest/example/celest/resources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions packages/celest_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.2-wip

- Adds `SecureStorage` interface for storage of sensitive data in the platform keychain.

## 0.2.1

- Overrides `toString` for `CloudException` types.
Expand Down
Loading

0 comments on commit 1ede4a9

Please sign in to comment.