Skip to content

Commit

Permalink
chore(examples): Update generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
dnys1 committed Mar 1, 2024
1 parent 78e4a4e commit 336ae8f
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 17 deletions.
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

0 comments on commit 336ae8f

Please sign in to comment.