Merge pull request #126 from dukefirehawk/feature/upgrade_sdk

Feature/upgrade sdk
This commit is contained in:
Thomas 2024-06-03 11:37:00 +08:00 committed by GitHub
commit 2698c4d753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 91 additions and 60 deletions

View file

@ -1,5 +1,10 @@
# Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.1.1
* Updated repository link

View file

@ -1,6 +1,6 @@
name: angel3_auth
description: A complete authentication plugin for Angel3. Includes support for stateless JWT tokens, Basic Auth, and more.
version: 8.1.1
version: 8.2.0
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth
environment:

View file

@ -1,5 +1,10 @@
# Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.1.1
* Updated repository link

View file

@ -1,5 +1,5 @@
name: angel3_auth_oauth2
version: 8.1.1
version: 8.2.0
description: Angel3 library for authenticating users with external identity providers via OAuth2.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth_oauth2

View file

@ -2,11 +2,11 @@
## 8.0.0
* Require Dart >= 3.0
* Require Dart >= 3.3
* Updated `oauth1` to `belatuk_oauth1`
* Updated `lints` to 3.0.0
* Fixed linter warnings
* Updated `lints` to 4.0.0
* Updated repository link
* Fixed linter warnings
## 7.0.0

View file

@ -5,6 +5,7 @@
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dart-backend/angel)](https://github.com/dart-backend/angel/tree/master/packages/auth_twitter/LICENSE)
**Not ready for release**
Angel3 authentication strategy using Twitter OAuth 1.0a.
See the [example](example/example.dart);

View file

@ -1,11 +1,11 @@
name: "angel3_auth_twitter"
description: Angel3 authentication strategy for Twitter login. Auto-signs requests.
version: 8.0.1
version: 8.0.0
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/auth_twitter
publish_to: none
environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">=3.3.0 <4.0.0"
dependencies:
angel3_auth: ^8.0.0
angel3_framework: ^8.0.0

View file

@ -1,5 +1,10 @@
# Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.1.1
* Updated repository link

View file

@ -1,10 +1,10 @@
name: angel3_cache
version: 8.1.1
version: 8.2.0
description: A service that provides HTTP caching to the response data for Angel3
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/cache
environment:
sdk: '>=3.3.0 <4.0.0'
sdk: '>=3.4.0 <4.0.0'
dependencies:
angel3_framework: ^8.0.0
collection: ^1.17.0

View file

@ -1,5 +1,10 @@
# Change Log
## 8.4.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.3.2
* Updated README

View file

@ -1,5 +1,5 @@
name: angel3_framework
version: 8.3.2
version: 8.4.0
description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/framework

View file

@ -1,5 +1,12 @@
# Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `mongo_dart` to 0.10.2
* Updated `lints` to 3.0.0
* Fixed deprecated methods
## 8.1.1
* Updated repository link

View file

@ -73,7 +73,7 @@ class MongoService extends Service<String, Map<String, dynamic>> {
for (var key in doc.keys) {
var value = doc[key];
if (value is ObjectId) {
result[key] = value.toHexString();
result[key] = value.oid;
} else if (value is! RequestContext && value is! ResponseContext) {
result[key] = value;
}
@ -133,7 +133,7 @@ class MongoService extends Service<String, Map<String, dynamic>> {
if (found == null) {
throw AngelHttpException.notFound(
message: 'No record found for ID ${localId.toHexString()}');
message: 'No record found for ID ${localId.oid}');
}
return _jsonify(found, params);
@ -171,7 +171,7 @@ class MongoService extends Service<String, Map<String, dynamic>> {
update: result,
returnNew: true) as FutureOr<Map<String, dynamic>>);
result = _jsonify(modified, params);
result['id'] = _makeId(id).toHexString();
result['id'] = _makeId(id).oid;
return result;
} catch (e, st) {
//printDebug(e, st, 'MODIFY');
@ -199,7 +199,7 @@ class MongoService extends Service<String, Map<String, dynamic>> {
returnNew: true,
upsert: true) as FutureOr<Map<String, dynamic>>);
result = _jsonify(updated, params);
result['id'] = _makeId(id).toHexString();
result['id'] = _makeId(id).oid;
return result;
} catch (e, st) {
//printDebug(e, st, 'UPDATE');

View file

@ -1,5 +1,5 @@
name: angel3_mongo
version: 8.1.1
version: 8.2.0
description: MongoDB-enabled services for the Angel3 framework. Well-tested.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/mongo
@ -9,7 +9,7 @@ dependencies:
angel3_framework: ^8.0.0
belatuk_json_serializer: ^7.1.0
belatuk_merge_map: ^5.1.0
mongo_dart: ^0.9.0
mongo_dart: ^0.10.2
dev_dependencies:
http: ^1.0.0
test: ^1.24.0

View file

@ -24,11 +24,12 @@ void main() {
group('Generic Tests', () {
Angel app;
late AngelHttp transport;
http.Client? client;
late http.Client client;
var db = Db('mongodb://localhost:27017/angel_mongo');
late DbCollection testData;
String? url;
HookedService<String, Map<String, dynamic>, MongoService>? greetingService;
late HookedService<String, Map<String, dynamic>, MongoService>
greetingService;
setUp(() async {
app = Angel();
@ -41,7 +42,7 @@ void main() {
var service = MongoService(testData);
greetingService = HookedService(service);
wireHooked(greetingService!);
wireHooked(greetingService);
app.use('/api', greetingService as Service);
@ -54,31 +55,28 @@ void main() {
await testData.remove(<String, dynamic>{});
await db.close();
await transport.close();
client = null;
url = null;
greetingService = null;
});
test('query fields mapped to filters', () async {
await greetingService!.create({'foo': 'bar'});
await greetingService.create({'foo': 'bar'});
expect(
await greetingService!.index({
await greetingService.index({
'query': {'foo': 'not bar'}
}),
isEmpty,
);
expect(
await greetingService!.index(),
await greetingService.index(),
isNotEmpty,
);
});
test('insert items', () async {
var response = await client!.post(Uri.parse('$url/api'),
var response = await client.post(Uri.parse('$url/api'),
body: god.serialize(testGreeting), headers: headers);
expect(response.statusCode, isIn([200, 201]));
response = await client!.get(Uri.parse('$url/api'));
response = await client.get(Uri.parse('$url/api'));
expect(response.statusCode, isIn([200, 201]));
var users = god.deserialize(response.body,
outputType: <Map>[].runtimeType) as List<Map>;
@ -86,12 +84,12 @@ void main() {
});
test('read item', () async {
var response = await client!.post(Uri.parse('$url/api'),
var response = await client.post(Uri.parse('$url/api'),
body: god.serialize(testGreeting), headers: headers);
expect(response.statusCode, isIn([200, 201]));
var created = god.deserialize(response.body) as Map;
response = await client!.get(Uri.parse("$url/api/${created['id']}"));
response = await client.get(Uri.parse("$url/api/${created['id']}"));
expect(response.statusCode, isIn([200, 201]));
var read = god.deserialize(response.body) as Map;
expect(read['id'], equals(created['id']));
@ -100,37 +98,37 @@ void main() {
});
test('findOne', () async {
var response = await client!.post(Uri.parse('$url/api'),
var response = await client.post(Uri.parse('$url/api'),
body: god.serialize(testGreeting), headers: headers);
expect(response.statusCode, isIn([200, 201]));
var created = god.deserialize(response.body) as Map;
var id = ObjectId.fromHexString(created['id'] as String);
var read = await greetingService!.findOne({'query': where.id(id)});
var read = await greetingService.findOne({'query': where.id(id)});
expect(read['id'], equals(created['id']));
expect(read['to'], equals('world'));
//expect(read['createdAt'], isNot(null));
});
test('readMany', () async {
var response = await client!.post(Uri.parse('$url/api'),
var response = await client.post(Uri.parse('$url/api'),
body: god.serialize(testGreeting), headers: headers);
expect(response.statusCode, isIn([200, 201]));
var created = god.deserialize(response.body) as Map;
var id = ObjectId.fromHexString(created['id'] as String);
var read = await greetingService!.readMany([id.toHexString()]);
var read = await greetingService.readMany([id.oid]);
expect(read, [created]);
//expect(read['createdAt'], isNot(null));
});
test('modify item', () async {
var response = await client!.post(Uri.parse('$url/api'),
var response = await client.post(Uri.parse('$url/api'),
body: god.serialize(testGreeting), headers: headers);
expect(response.statusCode, isIn([200, 201]));
var created = god.deserialize(response.body) as Map;
response = await client!.patch(Uri.parse("$url/api/${created['id']}"),
response = await client.patch(Uri.parse("$url/api/${created['id']}"),
body: god.serialize({'to': 'Mom'}), headers: headers);
var modified = god.deserialize(response.body) as Map;
expect(response.statusCode, isIn([200, 201]));
@ -140,12 +138,12 @@ void main() {
});
test('update item', () async {
var response = await client!.post(Uri.parse('$url/api'),
var response = await client.post(Uri.parse('$url/api'),
body: god.serialize(testGreeting), headers: headers);
expect(response.statusCode, isIn([200, 201]));
var created = god.deserialize(response.body) as Map;
response = await client!.post(Uri.parse("$url/api/${created['id']}"),
response = await client.post(Uri.parse("$url/api/${created['id']}"),
body: god.serialize({'to': 'Updated'}), headers: headers);
var modified = god.deserialize(response.body) as Map;
expect(response.statusCode, isIn([200, 201]));
@ -155,28 +153,28 @@ void main() {
});
test('remove item', () async {
var response = await client!.post(Uri.parse('$url/api'),
var response = await client.post(Uri.parse('$url/api'),
body: god.serialize(testGreeting), headers: headers);
var created = god.deserialize(response.body) as Map;
var lastCount = (await greetingService!.index()).length;
var lastCount = (await greetingService.index()).length;
await client!.delete(Uri.parse("$url/api/${created['id']}"));
expect((await greetingService!.index()).length, equals(lastCount - 1));
await client.delete(Uri.parse("$url/api/${created['id']}"));
expect((await greetingService.index()).length, equals(lastCount - 1));
});
test('cannot remove all unless explicitly set', () async {
var response = await client!.delete(Uri.parse('$url/api/null'));
var response = await client.delete(Uri.parse('$url/api/null'));
expect(response.statusCode, 403);
});
test('\$sort and query parameters', () async {
// Search by where.eq
Map world = await greetingService!.create({'to': 'world'});
await greetingService!.create({'to': 'Mom'});
await greetingService!.create({'to': 'Updated'});
Map world = await greetingService.create({'to': 'world'});
await greetingService.create({'to': 'Mom'});
await greetingService.create({'to': 'Updated'});
var response = await client!.get(Uri.parse('$url/api?to=world'));
var response = await client.get(Uri.parse('$url/api?to=world'));
print(response.body);
var queried = god.deserialize(response.body,
outputType: <Map>[].runtimeType) as List<Map>;
@ -193,7 +191,7 @@ void main() {
expect(queried[1]["id"], equals(Mom["id"]));
expect(queried[2]["id"], equals(world["id"]));*/
queried = await greetingService!.index({
queried = await greetingService.index({
'\$query': {
'_id': where.id(ObjectId.fromHexString(world['id'] as String))
}

View file

@ -1,5 +1,11 @@
# Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
* Updated `web_socket_channel` to 3.0.0
## 8.1.1
* Updated repository link

View file

@ -93,7 +93,7 @@ abstract class BaseWebSocketClient extends BaseAngelClient {
Future close() async {
on._close();
scheduleMicrotask(() async {
await _socket!.sink.close(status.goingAway);
await _socket!.sink.close(status.normalClosure);
await _onData.close();
await _onAllEvents.close();
await _onAuthenticated.close();

View file

@ -508,8 +508,8 @@ class AngelWebSocket {
if (protocol != null) sink.add('Sec-WebSocket-Protocol: $protocol\r\n');
sink.add('\r\n');
var ws = WebSocketChannel(ctrl.foreign);
var socket = WebSocketContext(ws, req, res);
//var ws = IOWebSocketChannel.connect(ctrl.foreign);
var socket = WebSocketContext(ctrl.foreign, req, res);
scheduleMicrotask(() => handleClient(socket));
return false;
}

View file

@ -1,5 +1,5 @@
name: angel3_websocket
version: 8.1.1
version: 8.2.0
description: This library provides WebSockets support for Angel3 framework.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/websocket
@ -14,14 +14,14 @@ dependencies:
http: ^1.0.0
meta: ^1.8.0
stream_channel: ^2.1.0
web_socket_channel: '>=2.1.0 <2.4.1'
web_socket_channel: ^3.0.0
collection: ^1.17.0
logging: ^1.1.0
dev_dependencies:
angel3_container: ^8.0.0
angel3_model: ^8.0.0
quiver: ^3.2.0
test: ^1.24.0
test: ^1.25.0
lints: ^4.0.0
file: ^7.0.0
# dependency_overrides:

View file

@ -11,7 +11,7 @@ import 'common.dart';
void main() {
srv.Angel app;
late srv.AngelHttp http;
ws.WebSockets? client;
late ws.WebSockets client;
srv.AngelWebSocket websockets;
HttpServer? server;
String? url;
@ -34,12 +34,12 @@ void main() {
url = 'ws://${server!.address.address}:${server!.port}/ws';
client = ws.WebSockets(url);
await client!.connect(timeout: Duration(seconds: 3));
await client.connect(timeout: Duration(seconds: 3));
print('Connected');
client
?..onData.listen((data) {
..onData.listen((data) {
print('Received by client: $data');
})
..onError.listen((error) {
@ -51,18 +51,17 @@ void main() {
});
tearDown(() async {
await client!.close();
await client.close();
await http.close();
//app = null;
client = null;
server = null;
url = null;
});
group('controller.io', () {
test('search', () async {
client!.sendAction(ws.WebSocketAction(eventName: 'search'));
var search = await client!.on['searched'].first;
client.sendAction(ws.WebSocketAction(eventName: 'search'));
var search = await client.on['searched'].first;
print('Searched: ${search.data}');
expect(Game.fromJson(search.data as Map), equals(johnVsBob));
});