diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index fffbe52c..5d16959e 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -21,7 +21,7 @@ jobs: - uses: dart-lang/setup-dart@v1 with: - sdk: "2.17.0" + sdk: "2.18.0" - id: angel3_container_upgrade name: angel3_container; Upgrade depedencies @@ -87,7 +87,7 @@ jobs: - uses: dart-lang/setup-dart@v1 with: - sdk: "2.17.0" + sdk: "2.18.0" # Angel3 ORM - id: angel3_orm_upgrade diff --git a/archived_packages/eventsource.zip b/archived_packages/eventsource.zip new file mode 100644 index 00000000..a1012dfd Binary files /dev/null and b/archived_packages/eventsource.zip differ diff --git a/archived_packages/eventsource/.gitignore b/archived_packages/eventsource/.gitignore deleted file mode 100644 index dbce896b..00000000 --- a/archived_packages/eventsource/.gitignore +++ /dev/null @@ -1,65 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# CMake -cmake-build-debug/ - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.packages -.pub/ -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ -.dart_tool \ No newline at end of file diff --git a/archived_packages/eventsource/LICENSE b/archived_packages/eventsource/LICENSE deleted file mode 100644 index 8f65b579..00000000 --- a/archived_packages/eventsource/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License (MIT) - -Copyright (c) 2021 dukefirehawk.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/archived_packages/eventsource/README.md b/archived_packages/eventsource/README.md deleted file mode 100644 index ea437ace..00000000 --- a/archived_packages/eventsource/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# eventsource -Server-sent Events (SSE) plugin for Angel. - -## Installation -In your `pubspec.yaml`: - -```yaml -dependencies: - angel_eventsource: ^1.0.0 -``` - -## Usage -SSE and WebSockets are somewhat similar in that they allow pushing of events from server -to client. SSE is not bi-directional, but the same abstractions used for WebSockets can be -applied to SSE easily. - -For this reason, the `AngelEventSourcePublisher` class is a simple adapter that -hands control of SSE requests to an existing `AngelWebSocket` driver. - -So, using this is pretty straightforward. You can dispatch events -via WebSocket as per usual, and have them propagated to SSE clients -as well. - -```dart -var app = new Angel(); -var ws = new AngelWebSocket(app); -var events = new AngelEventSourcePublisher(ws); - -await app.configure(ws.configureServer); - -app.all('/ws', ws.handleRequest); -app.get('/events', events.handleRequest); -``` \ No newline at end of file diff --git a/archived_packages/eventsource/analysis_options.yaml b/archived_packages/eventsource/analysis_options.yaml deleted file mode 100644 index eae1e42a..00000000 --- a/archived_packages/eventsource/analysis_options.yaml +++ /dev/null @@ -1,3 +0,0 @@ -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file diff --git a/archived_packages/eventsource/eventsource.iml b/archived_packages/eventsource/eventsource.iml deleted file mode 100644 index 5a5ced28..00000000 --- a/archived_packages/eventsource/eventsource.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/archived_packages/eventsource/example/main.dart b/archived_packages/eventsource/example/main.dart deleted file mode 100644 index f208544f..00000000 --- a/archived_packages/eventsource/example/main.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:angel_eventsource/server.dart'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -import 'package:angel_websocket/server.dart'; -import 'package:eventsource/eventsource.dart'; -import 'package:logging/logging.dart'; -import 'pretty_logging.dart'; - -main() async { - var app = new Angel(); - var ws = new AngelWebSocket(app); - var events = new AngelEventSourcePublisher(ws); - - await app.configure(ws.configureServer); - - app.use('/api/todos', new MapService()); - app.all('/ws', ws.handleRequest); - app.get('/events', events.handleRequest); - - app.logger = new Logger('angel_eventsource')..onRecord.listen(prettyLog); - - var http = new AngelHttp(app); - var server = await http.startServer('127.0.0.1', 3000); - var url = Uri.parse('http://${server.address.address}:${server.port}'); - print('Listening at $url'); - - /* - var sock = await Socket.connect(server.address, server.port); - sock - ..writeln('GET /sse HTTP/1.1') - ..writeln('Accept: text/event-stream') - ..writeln('Host: 127.0.0.1') - ..writeln() - ..flush(); - sock.transform(UTF8.decoder).transform(const LineSplitter()).listen(print); - */ - - /* - var client = new HttpClient(); - var rq = await client.openUrl('GET', url); - var rs = await rq.close(); - rs.transform(UTF8.decoder).transform(const LineSplitter()).listen(print); - */ - - var eventSource = await EventSource.connect(url); - - await for (var event in eventSource) { - print(event.data); - } -} diff --git a/archived_packages/eventsource/example/pretty_logging.dart b/archived_packages/eventsource/example/pretty_logging.dart deleted file mode 100644 index 883b979b..00000000 --- a/archived_packages/eventsource/example/pretty_logging.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:console/console.dart'; -import 'package:logging/logging.dart'; - -/// Prints the contents of a [LogRecord] with pretty colors. -prettyLog(LogRecord record) async { - var pen = new TextPen(); - chooseLogColor(pen.reset(), record.level); - pen(record.toString()); - - if (record.error != null) pen(record.error.toString()); - if (record.stackTrace != null) pen(record.stackTrace.toString()); - - pen(); -} - -/// Chooses a color based on the logger [level]. -void chooseLogColor(TextPen pen, Level level) { - if (level == Level.SHOUT) - pen.darkRed(); - else if (level == Level.SEVERE) - pen.red(); - else if (level == Level.WARNING) - pen.yellow(); - else if (level == Level.INFO) - pen.magenta(); - else if (level == Level.FINER) - pen.blue(); - else if (level == Level.FINEST) pen.darkBlue(); -} diff --git a/archived_packages/eventsource/lib/angel_eventsource.dart b/archived_packages/eventsource/lib/angel_eventsource.dart deleted file mode 100644 index 1071f8fc..00000000 --- a/archived_packages/eventsource/lib/angel_eventsource.dart +++ /dev/null @@ -1 +0,0 @@ -export 'package:angel_websocket/angel_websocket.dart'; diff --git a/archived_packages/eventsource/lib/server.dart b/archived_packages/eventsource/lib/server.dart deleted file mode 100644 index ea6c4e19..00000000 --- a/archived_packages/eventsource/lib/server.dart +++ /dev/null @@ -1,51 +0,0 @@ -import 'dart:async'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_websocket/server.dart'; -import 'package:eventsource/eventsource.dart'; -import 'package:eventsource/src/encoder.dart'; -import 'package:eventsource/publisher.dart'; -import 'package:stream_channel/stream_channel.dart'; - -class AngelEventSourcePublisher { - final AngelWebSocket webSocketDriver; - - final String channel; - - int _count = 0; - - AngelEventSourcePublisher(this.webSocketDriver, {this.channel: ''}); - - Future handleRequest(RequestContext req, ResponseContext res) async { - if (!req.accepts('text/event-stream', strict: false)) - throw new AngelHttpException.badRequest(); - - res.headers.addAll({ - 'cache-control': 'no-cache, no-store, must-revalidate', - 'content-type': 'text/event-stream', - 'connection': 'keep-alive', - }); - - var acceptsGzip = - (req.headers['accept-encoding']?.contains('gzip') == true); - - if (acceptsGzip) res.headers['content-encoding'] = 'gzip'; - - var eventSink = new EventSourceEncoder(compressed: acceptsGzip) - .startChunkedConversion(res); - - // Listen for events. - var ctrl = new StreamChannelController(); - - // Incoming events are strings, and should be sent via the eventSink. - ctrl.local.stream.cast().listen((data) { - eventSink.add(new Event( - id: (_count++).toString(), - data: data, - )); - }); - - // Create a new WebSocketContext, and hand it off to the driver. - var socket = new WebSocketContext(ctrl.foreign, req, res); - return await webSocketDriver.handleClient(socket); - } -} diff --git a/archived_packages/eventsource/pubspec.yaml b/archived_packages/eventsource/pubspec.yaml deleted file mode 100644 index d13748e2..00000000 --- a/archived_packages/eventsource/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: angel_eventsource -version: 2.0.0 -description: Server-sent Events (SSE) plugin for Angel. -homepage: https://github.com/angel-dart/eventsource -publish_to: none -environment: - sdk: ">=2.10.0 <3.0.0" -dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x - path: packages/framework - angel_websocket: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x - path: packages/websocket - eventsource: - git: - url: https://github.com/dukefirehawk/dart-eventsource.git - stream_channel: ^2.0.0 -dev_dependencies: - console: ^4.0.0 - logging: ^1.0.0 - test: ^1.16.5 diff --git a/archived_packages/orm.zip b/archived_packages/orm.zip new file mode 100644 index 00000000..7b0436e8 Binary files /dev/null and b/archived_packages/orm.zip differ diff --git a/archived_packages/orm/angel_orm_sqlite/LICENSE b/archived_packages/orm/angel_orm_sqlite/LICENSE deleted file mode 100644 index 8f65b579..00000000 --- a/archived_packages/orm/angel_orm_sqlite/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License (MIT) - -Copyright (c) 2021 dukefirehawk.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/archived_packages/orm/angel_orm_sqlite/pubspec.yaml b/archived_packages/orm/angel_orm_sqlite/pubspec.yaml deleted file mode 100644 index 6e2d9082..00000000 --- a/archived_packages/orm/angel_orm_sqlite/pubspec.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: angel_orm_sqlite -environment: - sdk: ">=2.16.0 <3.0.0" -dependencies: - angel_orm: ^2.0.0-dev diff --git a/archived_packages/poll.zip b/archived_packages/poll.zip new file mode 100644 index 00000000..4442e486 Binary files /dev/null and b/archived_packages/poll.zip differ diff --git a/archived_packages/poll/.gitignore b/archived_packages/poll/.gitignore deleted file mode 100644 index b4d6e266..00000000 --- a/archived_packages/poll/.gitignore +++ /dev/null @@ -1,64 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# CMake -cmake-build-debug/ - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.packages -.pub/ -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ diff --git a/archived_packages/poll/.travis.yml b/archived_packages/poll/.travis.yml deleted file mode 100644 index de2210c9..00000000 --- a/archived_packages/poll/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: dart \ No newline at end of file diff --git a/archived_packages/poll/AUTHORS.md b/archived_packages/poll/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/archived_packages/poll/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - Thomas is the current maintainer of the code base. He has refactored and migrated the - code base to support NNBD. - -* __[Tobe O](thosakwe@gmail.com)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/archived_packages/poll/CHANGELOG.md b/archived_packages/poll/CHANGELOG.md deleted file mode 100644 index d531223a..00000000 --- a/archived_packages/poll/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Change Log - -## 2.0.0 - -* Migrated to support Dart >= 2.12 NNBD - -## 1.0.0 - -* Created package + tests diff --git a/archived_packages/poll/LICENSE b/archived_packages/poll/LICENSE deleted file mode 100644 index df5e0635..00000000 --- a/archived_packages/poll/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2021, dukefirehawk.com -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/archived_packages/poll/README.md b/archived_packages/poll/README.md deleted file mode 100644 index de25152b..00000000 --- a/archived_packages/poll/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# poll -[![Pub](https://img.shields.io/pub/v/angel_poll.svg)](https://pub.dartlang.org/packages/angel_poll) -[![build status](https://travis-ci.org/angel-dart/poll.svg?branch=master)](https://travis-ci.org/angel-dart/poll) - -`package:angel_client` support for "realtime" interactions with Angel via long polling. - -Angel supports [WebSockets](https://github.com/angel-dart/websocket) on the server and client, which -makes it very straightforward to implement realtime collections. However, not every user's browser -supports WebSockets. In such a case, applications might *gracefully degrade* to long-polling -the server for changes. - -A `PollingService` wraps a client-side `Service` (typically a REST-based one), and calls its -`index` method at a regular interval. After indexing, the `PollingService` performs a diff -and identifies whether items have been created, modified, or removed. The updates are sent out -through `onCreated`, `onModified`, etc., effectively managing a real-time collection of data. - -A common use-case would be passing this service to `ServiceList`, a class that manages the state -of a collection managed in real-time. - -```dart -import 'package:angel_client/io.dart'; -import 'package:angel_poll/angel_poll.dart'; - -main() { - var app = new Rest('http://localhost:3000'); - - var todos = new ServiceList( - new PollingService( - // Typically, you'll pass a REST-based service instance here. - app.service('api/todos'), - - // `index` called every 5 seconds - const Duration(seconds: 5), - ), - ); - - todos.onChange.listen((_) { - // Something happened here. - // Maybe an item was created, modified, etc. - }); -} -``` \ No newline at end of file diff --git a/archived_packages/poll/analysis_options.yaml b/archived_packages/poll/analysis_options.yaml deleted file mode 100644 index ea2c9e94..00000000 --- a/archived_packages/poll/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml \ No newline at end of file diff --git a/archived_packages/poll/example/main.dart b/archived_packages/poll/example/main.dart deleted file mode 100644 index 4b8e2739..00000000 --- a/archived_packages/poll/example/main.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:angel_client/io.dart'; -import 'package:angel_poll/angel_poll.dart'; - -void main() { - var app = Rest('http://localhost:3000'); - - var todos = ServiceList( - PollingService( - // Typically, you'll pass a REST-based service instance here. - app.service('api/todos'), - - // `index` called every 5 seconds - const Duration(seconds: 5), - ), - ); - - todos.onChange.listen((_) { - // Something happened here. - // Maybe an item was created, modified, etc. - }); -} diff --git a/archived_packages/poll/lib/angel_poll.dart b/archived_packages/poll/lib/angel_poll.dart deleted file mode 100644 index 7c245258..00000000 --- a/archived_packages/poll/lib/angel_poll.dart +++ /dev/null @@ -1,265 +0,0 @@ -import 'dart:async'; -import 'package:collection/collection.dart'; -import 'package:angel_client/angel_client.dart'; - -/// A [Service] that facilitates real-time updates via the long polling of an [inner] service. -/// -/// Works well with [ServiceList]. -class PollingService extends Service { - /// The underlying [Service] that does the actual communication with the server. - final Service inner; - - /// Perform computations after polling to discern whether new items were created. - final bool checkForCreated; - - /// Perform computations after polling to discern whether items were modified. - final bool checkForModified; - - /// Perform computations after polling to discern whether items were removed. - final bool checkForRemoved; - - /// An [EqualityBy] used to compare the ID's of two items. - /// - /// Defaults to comparing the [idField] of two `Map` instances. - final EqualityBy compareId; - - /// An [Equality] used to discern whether two items, with the same [idField], are the same item. - /// - /// Defaults to [MapEquality], which deep-compares `Map` instances. - final Equality compareItems; - - /// A [String] used as an index through which to compare `Map` instances. - /// - /// Defaults to `id`. - final String idField; - - /// If `true` (default: `false`), then `index` events will be handled as a [Map] containing a `data` field. - /// - /// See https://github.com/angel-dart/paginate. - final bool asPaginated; - - final List _items = []; - final List _subs = []; - - final StreamController> _onIndexed = StreamController(), - _onRead = StreamController(), - _onCreated = StreamController(), - _onModified = StreamController(), - _onUpdated = StreamController(), - _onRemoved = StreamController(); - - late Timer _timer; - - @override - Angel get app => inner.app; - - @override - Stream> get onIndexed => _onIndexed.stream; - - @override - Stream get onRead => _onRead.stream; - - @override - Stream get onCreated => _onCreated.stream; - - @override - Stream get onModified => _onModified.stream; - - @override - Stream get onUpdated => _onUpdated.stream; - - @override - Stream get onRemoved => _onRemoved.stream; - - PollingService(this.inner, Duration interval, - {this.checkForCreated = true, - this.checkForModified = true, - this.checkForRemoved = true, - this.idField = 'id', - this.asPaginated = false, - EqualityBy? compareId, - this.compareItems = const MapEquality()}) - : compareId = compareId ?? EqualityBy((map) => map[idField]) { - _timer = Timer.periodic(interval, (_) { - index().catchError((error) { - _onIndexed.addError(error as Object); - }); - }); - - var streams = { - inner.onRead: _onRead, - inner.onCreated: _onCreated, - inner.onModified: _onModified, - inner.onUpdated: _onUpdated, - inner.onRemoved: _onRemoved, - }; - - streams.forEach((stream, ctrl) { - _subs.add(stream.listen(ctrl.add, onError: ctrl.addError)); - }); - - _subs.add( - inner.onIndexed.listen( - _handleIndexed, - onError: _onIndexed.addError, - ), - ); - } - - @override - Future close() async { - _timer.cancel(); - for (var s in _subs) { - s.cancel(); - } - await _onIndexed.close(); - await _onRead.close(); - await _onCreated.close(); - await _onModified.close(); - await _onUpdated.close(); - await _onRemoved.close(); - } - - // TODO: To revisit this logic - @override - Future> index([Map? params]) { - return inner.index().then((data) { - //return asPaginated == true ? data['data'] : data; - //return asPaginated == true ? data[0] : data; - return data; - }); - } - -/* - @override - Future index([Map params]) { - } -*/ - @override - Future remove(id, [Map? params]) { - return inner.remove(id, params).then((result) { - _items.remove(result); - return result; - }).catchError(_onRemoved.addError); - } - - dynamic _handleUpdate(result) { - var index = -1; - - for (var i = 0; i < _items.length; i++) { - if (compareId.equals(_items[i], result)) { - index = i; - break; - } - } - - if (index > -1) { - _items[index] = result; - } - - return result; - } - - @override - Future update(id, data, [Map? params]) { - return inner - .update(id, data, params) - .then(_handleUpdate) - .catchError(_onUpdated.addError); - } - - @override - Future modify(id, data, [Map? params]) { - return inner - .modify(id, data, params) - .then(_handleUpdate) - .catchError(_onModified.addError); - } - - @override - Future create(data, [Map? params]) { - return inner.create(data, params).then((result) { - _items.add(result); - return result; - }).catchError(_onCreated.addError); - } - - @override - Future read(id, [Map? params]) { - return inner.read(id, params); - } - - void _handleIndexed(List data) { - //var items = asPaginated == true ? data['data'] : data; - var items = data; - var changesComputed = false; - - if (checkForCreated != false) { - var newItems = {}; - - for (var i = 0; i < items.length; i++) { - var item = items[i]; - - if (!_items.any((i) => compareId.equals(i, item))) { - newItems[i] = item; - } - } - - newItems.forEach((index, item) { - _items.insert(index, item); - _onCreated.add([item]); - }); - - changesComputed = newItems.isNotEmpty; - } - - if (checkForRemoved != false) { - var removedItems = {}; - - for (var i = 0; i < _items.length; i++) { - var item = _items[i]; - - if (!items.any((i) => compareId.equals(i, item))) { - removedItems[i] = item; - } - } - - removedItems.forEach((index, item) { - _items.removeAt(index); - _onRemoved.add([item]); - }); - - changesComputed = changesComputed || removedItems.isNotEmpty; - } - - if (checkForModified != false) { - var modifiedItems = {}; - - for (var item in items) { - for (var i = 0; i < _items.length; i++) { - var localItem = _items[i]; - - if (compareId.equals(item, localItem)) { - if (!compareItems.equals(item, localItem)) { - modifiedItems[i] = item; - } - break; - } - } - } - - modifiedItems.forEach((index, item) { - _onModified.add([_items[index] = item]); - }); - - changesComputed = changesComputed || modifiedItems.isNotEmpty; - } - - if (!changesComputed) { - _items - ..clear() - ..add(items); - _onIndexed.add([items]); - } - } -} diff --git a/archived_packages/poll/poll.iml b/archived_packages/poll/poll.iml deleted file mode 100644 index 5a5ced28..00000000 --- a/archived_packages/poll/poll.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/archived_packages/poll/pubspec.yaml b/archived_packages/poll/pubspec.yaml deleted file mode 100644 index 683825f2..00000000 --- a/archived_packages/poll/pubspec.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: angel_poll -version: 2.0.0 -description: package:angel_client support for "realtime" interactions with Angel via long polling. -publish_to: none -environment: - sdk: '>=2.12.0 <3.0.0' -homepage: https://github.com/angel-dart/poll -dependencies: - angel_client: # ^1.0.0 - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/client - async: ^2.7.0 - collection: ^1.15.0 -dev_dependencies: - angel_test: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/test - test: ^1.17.8 - lints: ^1.0.0 \ No newline at end of file diff --git a/archived_packages/poll/test/all_test.dart b/archived_packages/poll/test/all_test.dart deleted file mode 100644 index f709af1e..00000000 --- a/archived_packages/poll/test/all_test.dart +++ /dev/null @@ -1,105 +0,0 @@ -import 'package:angel_framework/angel_framework.dart' as srv; -import 'package:angel_container/mirrors.dart'; -import 'package:angel_poll/angel_poll.dart'; -import 'package:angel_test/angel_test.dart'; -import 'package:async/async.dart'; -import 'package:logging/logging.dart'; -import 'package:test/test.dart'; - -void main() { - late srv.Service store; - late TestClient client; - late PollingService pollingService; - - var created; - late StreamQueue onCreated; - late StreamQueue onModified; - late StreamQueue onRemoved; - - setUp(() async { - var app = srv.Angel(reflector: MirrorsReflector()); - app.logger = Logger.detached('angel_poll') - ..onRecord.listen((rec) { - print(rec); - if (rec.error != null) { - print(rec.error); - print(rec.stackTrace); - } - }); - - store = app.use( - '/api/todos', - srv.MapService( - autoIdAndDateFields: false, - ), - ); - - client = await connectTo(app); - - pollingService = PollingService( - client.service('api/todos'), - const Duration(milliseconds: 100), - ); - - onCreated = StreamQueue(pollingService.onCreated); - onModified = StreamQueue(pollingService.onModified); - onRemoved = StreamQueue(pollingService.onRemoved); - - created = await store.create({ - 'id': '0', - 'text': 'Clean your room', - 'completed': false, - }); - }); - - tearDown(() { - onCreated.cancel(); - onModified.cancel(); - onRemoved.cancel(); - client.close(); - }); - - group('events', () { - test('fires indexed', () async { - var indexed = await pollingService.index(); - print(indexed); - expect(await pollingService.onIndexed.first, indexed); - }); - - test('fires created', () async { - var result = await onCreated.next; - print(result); - expect(created, result); - }); - - test('fires modified', () async { - await pollingService.index(); - await store.modify('0', { - 'text': 'go to school', - }); - - var result = await onModified.next; - print(result); - expect(result, Map.from({'': created})..['text'] = 'go to school'); - }); - - test('manual modify', () async { - await pollingService.index(); - await pollingService.modify('0', { - 'text': 'eat', - }); - - var result = await onModified.next; - print(result); - expect(result, Map.from({'': created})..['text'] = 'eat'); - }); - - test('fires removed', () async { - await pollingService.index(); - var removed = await store.remove('0'); - var result = await onRemoved.next; - print(result); - expect(result, removed); - }); - }); -} diff --git a/archived_packages/relations.zip b/archived_packages/relations.zip new file mode 100644 index 00000000..cb9c59e6 Binary files /dev/null and b/archived_packages/relations.zip differ diff --git a/archived_packages/relations/.gitignore b/archived_packages/relations/.gitignore deleted file mode 100644 index e822a056..00000000 --- a/archived_packages/relations/.gitignore +++ /dev/null @@ -1,93 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.buildlog -.packages -.project -.pub/ -.scripts-bin/ -build/ -**/packages/ - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc -doc/api/ - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -pubspec.lock -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/archived_packages/relations/.travis.yml b/archived_packages/relations/.travis.yml deleted file mode 100644 index de2210c9..00000000 --- a/archived_packages/relations/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: dart \ No newline at end of file diff --git a/archived_packages/relations/AUTHORS.md b/archived_packages/relations/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/archived_packages/relations/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - Thomas is the current maintainer of the code base. He has refactored and migrated the - code base to support NNBD. - -* __[Tobe O](thosakwe@gmail.com)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/archived_packages/relations/CHANGELOG.md b/archived_packages/relations/CHANGELOG.md deleted file mode 100644 index 9a5d3f9b..00000000 --- a/archived_packages/relations/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Change Log - -## 2.0.0 - -* Migrated to support Dart >= 2.12 NNBD - -## 1.0.0 - -* Initial checkin diff --git a/archived_packages/relations/LICENSE b/archived_packages/relations/LICENSE deleted file mode 100644 index df5e0635..00000000 --- a/archived_packages/relations/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2021, dukefirehawk.com -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/archived_packages/relations/README.md b/archived_packages/relations/README.md deleted file mode 100644 index ea8a4e74..00000000 --- a/archived_packages/relations/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# relations -[![version 1.0.1](https://img.shields.io/badge/pub-v1.0.1-brightgreen.svg)](https://pub.dartlang.org/packages/angel_relations) -[![build status](https://travis-ci.org/angel-dart/relations.svg)](https://travis-ci.org/angel-dart/relations) - -Database-agnostic relations between Angel services. - -```dart -// Authors owning one book -app.service('authors').afterAll( - relations.hasOne('books', as: 'book', foreignKey: 'authorId')); - -// Or multiple -app.service('authors').afterAll( - relations.hasMany('books', foreignKey: 'authorId')); - -// Or, books belonging to authors -app.service('books').afterAll(relations.belongsTo('authors')); -``` - -Supports: -* `hasOne` -* `hasMany` -* `hasManyThrough` -* `belongsTo` -* `belongsToMany` \ No newline at end of file diff --git a/archived_packages/relations/analysis_options.yaml b/archived_packages/relations/analysis_options.yaml deleted file mode 100644 index ea2c9e94..00000000 --- a/archived_packages/relations/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml \ No newline at end of file diff --git a/archived_packages/relations/lib/angel_relations.dart b/archived_packages/relations/lib/angel_relations.dart deleted file mode 100644 index 5f2b6a7e..00000000 --- a/archived_packages/relations/lib/angel_relations.dart +++ /dev/null @@ -1,9 +0,0 @@ -/// Hooks to populate data returned from services, in a fashion -/// reminiscent of a relational database. -library angel_relations; - -export 'src/belongs_to_many.dart'; -export 'src/belongs_to.dart'; -export 'src/has_many.dart'; -export 'src/has_many_through.dart'; -export 'src/has_one.dart'; \ No newline at end of file diff --git a/archived_packages/relations/lib/src/belongs_to.dart b/archived_packages/relations/lib/src/belongs_to.dart deleted file mode 100644 index bf05f84c..00000000 --- a/archived_packages/relations/lib/src/belongs_to.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'dart:async'; -import 'dart:mirrors'; -import 'package:angel_framework/angel_framework.dart'; -import 'plural.dart' as pluralize; -import 'no_service.dart'; - -/// Represents a relationship in which the current [service] "belongs to" -/// a single member of the service at [servicePath]. Use [as] to set the name -/// on the target object. -/// -/// Defaults: -/// * [localKey]: `userId` -/// * [foreignKey]: `id` -HookedServiceEventListener belongsTo(Pattern servicePath, - {String? as, - String? foreignKey, - String? localKey, - Function(dynamic obj)? getForeignKey, - Function(dynamic foreign, dynamic obj)? assignForeignObject}) { - var localId = localKey; - var foreignName = - as?.isNotEmpty == true ? as! : pluralize.singular(servicePath.toString()); - - localId ??= foreignName + 'Id'; - - return (HookedServiceEvent e) async { - var ref = e.getService(servicePath); - if (ref == null) throw noService(servicePath); - - dynamic _getForeignKey(obj) { - if (getForeignKey != null) { - return getForeignKey(obj); - } else if (obj is Map) { - return obj[localId]; - } else if (localId == null || localId == 'userId') { - return obj.userId; - } else { - return reflect(obj).getField(Symbol(localId)).reflectee; - } - } - - dynamic _assignForeignObject(foreign, obj) { - if (assignForeignObject != null) { - return assignForeignObject(foreign, obj); - } else if (obj is Map) { - obj[foreignName] = foreign; - } else { - reflect(obj).setField(Symbol(foreignName), foreign); - } - } - - Future _normalize(obj) async { - if (obj != null) { - var id = await _getForeignKey(obj); - var indexed = await ref.index({ - 'query': {foreignKey ?? 'id': id} - }); - - if (indexed is! List || indexed.isNotEmpty != true) { - await _assignForeignObject(null, obj); - } else { - var child = indexed.first; - await _assignForeignObject(child, obj); - } - } - } - - if (e.result is Iterable) { - //await Future.wait(e.result.map(_normalize)); - await e.result.map(_normalize); - } else { - await _normalize(e.result); - } - }; -} diff --git a/archived_packages/relations/lib/src/belongs_to_many.dart b/archived_packages/relations/lib/src/belongs_to_many.dart deleted file mode 100644 index 7ee4d2f9..00000000 --- a/archived_packages/relations/lib/src/belongs_to_many.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'dart:async'; -import 'dart:mirrors'; -import 'package:angel_framework/angel_framework.dart'; -import 'plural.dart' as pluralize; -import 'no_service.dart'; - -/// Represents a relationship in which the current [service] "belongs to" -/// multiple members of the service at [servicePath]. Use [as] to set the name -/// on the target object. -/// -/// Defaults: -/// * [foreignKey]: `userId` -/// * [localKey]: `id` -HookedServiceEventListener belongsToMany(Pattern servicePath, - {String? as, - String? foreignKey, - String? localKey, - Function(dynamic obj)? getForeignKey, - Function(dynamic foreign, dynamic obj)? assignForeignObject}) { - var localId = localKey; - var foreignName = - as?.isNotEmpty == true ? as! : pluralize.plural(servicePath.toString()); - - localId ??= foreignName + 'Id'; - - return (HookedServiceEvent e) async { - var ref = e.getService(servicePath); - if (ref == null) throw noService(servicePath); - - dynamic _getForeignKey(obj) { - if (getForeignKey != null) { - return getForeignKey(obj); - } else if (obj is Map) { - return obj[localId]; - } else if (localId == null || localId == 'userId') { - return obj.userId; - } else { - return reflect(obj).getField(Symbol(localId)).reflectee; - } - } - - dynamic _assignForeignObject(foreign, obj) { - if (assignForeignObject != null) { - return assignForeignObject(foreign as List?, obj); - } else if (obj is Map) { - obj[foreignName] = foreign; - } else { - reflect(obj).setField(Symbol(foreignName), foreign); - } - } - - Future _normalize(obj) async { - if (obj != null) { - var id = await _getForeignKey(obj); - var indexed = await ref.index({ - 'query': {foreignKey ?? 'id': id} - }); - - if (indexed is! List || indexed.isNotEmpty != true) { - await _assignForeignObject(null, obj); - } else { - var child = indexed is Iterable ? indexed.toList() : [indexed]; - await _assignForeignObject(child, obj); - } - } - } - - if (e.result is Iterable) { - //await Future.wait(e.result.map(_normalize)); - await e.result.map(_normalize); - } else { - await _normalize(e.result); - } - }; -} diff --git a/archived_packages/relations/lib/src/has_many.dart b/archived_packages/relations/lib/src/has_many.dart deleted file mode 100644 index cca4e9e6..00000000 --- a/archived_packages/relations/lib/src/has_many.dart +++ /dev/null @@ -1,70 +0,0 @@ -import 'dart:async'; -import 'dart:mirrors'; -import 'package:angel_framework/angel_framework.dart'; -import 'plural.dart' as pluralize; -import 'no_service.dart'; - -/// Represents a relationship in which the current [service] "owns" -/// members of the service at [servicePath]. Use [as] to set the name -/// on the target object. -/// -/// Defaults: -/// * [foreignKey]: `userId` -/// * [localKey]: `id` -HookedServiceEventListener hasMany(Pattern servicePath, - {String? as, - String? foreignKey, - String? localKey, - Function(dynamic obj)? getLocalKey, - Function(dynamic foreign, dynamic obj)? assignForeignObjects}) { - return (HookedServiceEvent e) async { - var ref = e.getService(servicePath); - var foreignName = - as?.isNotEmpty == true ? as : pluralize.plural(servicePath.toString()); - if (ref == null) throw noService(servicePath); - - dynamic _getLocalKey(obj) { - if (getLocalKey != null) { - return getLocalKey(obj); - } else if (obj is Map) { - return obj[localKey ?? 'id']; - } else if (localKey == null || localKey == 'id') { - return obj.id; - } else { - return reflect(obj).getField(Symbol(localKey)).reflectee; - } - } - - dynamic _assignForeignObjects(foreign, obj) { - if (assignForeignObjects != null) { - return assignForeignObjects(foreign, obj); - } else if (obj is Map) { - obj[foreignName] = foreign; - } else { - reflect(obj).setField(Symbol(foreignName!), foreign); - } - } - - Future _normalize(obj) async { - if (obj != null) { - var id = await _getLocalKey(obj); - var indexed = await ref.index({ - 'query': {foreignKey ?? 'userId': id} - }); - - if (indexed is! List || indexed.isNotEmpty != true) { - await _assignForeignObjects([], obj); - } else { - await _assignForeignObjects(indexed, obj); - } - } - } - - if (e.result is Iterable) { - //await Future.wait(e.result.map(_normalize)); - await e.result.map(_normalize); - } else { - await _normalize(e.result); - } - }; -} diff --git a/archived_packages/relations/lib/src/has_many_through.dart b/archived_packages/relations/lib/src/has_many_through.dart deleted file mode 100644 index 23a6ed1d..00000000 --- a/archived_packages/relations/lib/src/has_many_through.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'dart:async'; -import 'dart:mirrors'; -import 'package:angel_framework/angel_framework.dart'; -import 'plural.dart' as pluralize; -import 'no_service.dart'; - -HookedServiceEventListener hasManyThrough(String servicePath, String pivotPath, - {String? as, - String? localKey, - String? pivotKey, - String? foreignKey, - Function(dynamic obj)? getLocalKey, - Function(dynamic obj)? getPivotKey, - Function(dynamic obj)? getForeignKey, - Function(dynamic foreign, dynamic obj)? assignForeignObjects}) { - var foreignName = - as?.isNotEmpty == true ? as : pluralize.plural(servicePath.toString()); - - return (HookedServiceEvent e) async { - var pivotService = e.getService(pivotPath); - var foreignService = e.getService(servicePath); - - if (pivotService == null) { - throw noService(pivotPath); - } else if (foreignService == null) throw noService(servicePath); - - dynamic _assignForeignObjects(foreign, obj) { - if (assignForeignObjects != null) { - return assignForeignObjects(foreign, obj); - } else if (obj is Map) { - obj[foreignName] = foreign; - } else { - reflect(obj).setField(Symbol(foreignName!), foreign); - } - } - - dynamic _getLocalKey(obj) { - if (getLocalKey != null) { - return getLocalKey(obj); - } else if (obj is Map) { - return obj[localKey ?? 'id']; - } else if (localKey == null || localKey == 'id') { - return obj.id; - } else { - return reflect(obj).getField(Symbol(localKey)).reflectee; - } - } - - dynamic _getPivotKey(obj) { - if (getPivotKey != null) { - return getPivotKey(obj); - } else if (obj is Map) { - return obj[pivotKey ?? 'id']; - } else if (pivotKey == null || pivotKey == 'id') { - return obj.id; - } else { - return reflect(obj).getField(Symbol(pivotKey)).reflectee; - } - } - - Future _normalize(obj) async { - // First, resolve pivot - var id = await _getLocalKey(obj); - var indexed = await pivotService.index({ - 'query': {pivotKey ?? 'userId': id} - }); - - if (indexed is! List || indexed.isNotEmpty != true) { - await _assignForeignObjects([], obj); - } else { - // Now, resolve from foreign service - var mapped = await Future.wait(indexed.map((pivot) async { - var id = await _getPivotKey(obj); - var indexed = await foreignService.index({ - 'query': {foreignKey ?? 'postId': id} - }); - - if (indexed is! List || indexed.isNotEmpty != true) { - await _assignForeignObjects([], pivot); - } else { - await _assignForeignObjects(indexed, pivot); - } - - return pivot; - })); - await _assignForeignObjects(mapped, obj); - } - } - - if (e.result is Iterable) { - //await Future.wait(e.result.map(_normalize)); - await e.result.map(_normalize); - } else { - await _normalize(e.result); - } - }; -} diff --git a/archived_packages/relations/lib/src/has_one.dart b/archived_packages/relations/lib/src/has_one.dart deleted file mode 100644 index d463e823..00000000 --- a/archived_packages/relations/lib/src/has_one.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'dart:async'; -import 'dart:mirrors'; -import 'package:angel_framework/angel_framework.dart'; -import 'plural.dart' as pluralize; -import 'no_service.dart'; - -/// Represents a relationship in which the current [service] "owns" -/// a single member of the service at [servicePath]. Use [as] to set the name -/// on the target object. -/// -/// Defaults: -/// * [foreignKey]: `userId` -/// * [localKey]: `id` -HookedServiceEventListener hasOne(Pattern servicePath, - {String? as, - String? foreignKey, - String? localKey, - Function(dynamic obj)? getLocalKey, - Function(dynamic foreign, dynamic obj)? assignForeignObject}) { - return (HookedServiceEvent e) async { - var ref = e.getService(servicePath); - var foreignName = as?.isNotEmpty == true - ? as - : pluralize.singular(servicePath.toString()); - if (ref == null) throw noService(servicePath); - - dynamic _getLocalKey(obj) { - if (getLocalKey != null) { - return getLocalKey(obj); - } else if (obj is Map) { - return obj[localKey ?? 'id']; - } else if (localKey == null || localKey == 'id') { - return obj.id; - } else { - return reflect(obj).getField(Symbol(localKey)).reflectee; - } - } - - dynamic _assignForeignObject(foreign, obj) { - if (assignForeignObject != null) { - return assignForeignObject(foreign, obj); - } else if (obj is Map) { - obj[foreignName] = foreign; - } else { - reflect(obj).setField(Symbol(foreignName!), foreign); - } - } - - Future _normalize(obj) async { - if (obj != null) { - var id = await _getLocalKey(obj); - - var indexed = await ref.index({ - 'query': {foreignKey ?? 'userId': id} - }); - - if (indexed is! List || indexed.isNotEmpty != true) { - await _assignForeignObject(null, obj); - } else { - var child = indexed.first; - await _assignForeignObject(child, obj); - } - } - } - - if (e.result is Iterable) { - //await Future.wait(e.result.map(_normalize)); - await e.result.map(_normalize); - } else { - await _normalize(e.result); - } - }; -} diff --git a/archived_packages/relations/lib/src/no_service.dart b/archived_packages/relations/lib/src/no_service.dart deleted file mode 100644 index df8eb3c4..00000000 --- a/archived_packages/relations/lib/src/no_service.dart +++ /dev/null @@ -1,2 +0,0 @@ -ArgumentError noService(Pattern path) => - ArgumentError("No service exists at path '$path'."); diff --git a/archived_packages/relations/lib/src/plural.dart b/archived_packages/relations/lib/src/plural.dart deleted file mode 100644 index 2c94bb89..00000000 --- a/archived_packages/relations/lib/src/plural.dart +++ /dev/null @@ -1,23 +0,0 @@ -String singular(String path) { - var str = path.trim().split('/').where((str) => str.isNotEmpty).last; - - if (str.endsWith('ies')) { - return str.substring(0, str.length - 3) + 'y'; - } else if (str.endsWith('s')) { - return str.substring(0, str.length - 1); - } else { - return str; - } -} - -String plural(String path) { - var str = path.trim().split('/').where((str) => str.isNotEmpty).last; - - if (str.endsWith('y')) { - return str.substring(0, str.length - 1) + 'ies'; - } else if (str.endsWith('s')) { - return str; - } else { - return str + 's'; - } -} diff --git a/archived_packages/relations/pubspec.yaml b/archived_packages/relations/pubspec.yaml deleted file mode 100644 index 53f427c4..00000000 --- a/archived_packages/relations/pubspec.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: angel_relations -version: 2.0.0 -description: Database-agnostic relations between Angel services. -homepage: "https://github.com/angel-dart/relations.git" -publish_to: none -environment: - sdk: '>=2.12.0 <3.0.0' -dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework -dev_dependencies: - angel_seeder: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/seeder - test: ^1.17.8 - lints: ^1.0.0 diff --git a/archived_packages/relations/test/belongs_to_test.dart b/archived_packages/relations/test/belongs_to_test.dart deleted file mode 100644 index 06e2746a..00000000 --- a/archived_packages/relations/test/belongs_to_test.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_seeder/angel_seeder.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - late Angel app; - - setUp(() async { - app = Angel()..use('/authors', MapService())..use('/books', MapService()); - - await app.configure(seed( - 'authors', - SeederConfiguration( - count: 10, - template: {'name': (Faker faker) => faker.person.name()}, - callback: (Map author, seed) { - return seed( - 'books', - SeederConfiguration(delete: false, count: 10, template: { - 'authorId': author['id'], - 'title': (Faker faker) => - 'I love to eat ${faker.food.dish()}' - })); - }))); - - // TODO: Missing method afterAll - //app.findService ('books').afterAll(relations.belongsTo('authors')); - }); - - test('index', () async { - var books = await app.findService('books')!.index(); - print(books); - - expect(books, allOf(isList, isNotEmpty)); - - for (var book in books.whereType()) { - expect(book.keys, contains('author')); - - var author = book['author'] as Map; - expect(author['id'], equals(book['authorId'])); - } - }); - - test('create', () async { - var warAndPeace = await app - .findService('books')! - .create(Book(title: 'War and Peace').toJson()); - - print(warAndPeace); - expect(warAndPeace.keys, contains('author')); - expect(warAndPeace['author'], isNull); - }); -} diff --git a/archived_packages/relations/test/common.dart b/archived_packages/relations/test/common.dart deleted file mode 100644 index b1d002e2..00000000 --- a/archived_packages/relations/test/common.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'dart:convert'; -import 'package:angel_framework/angel_framework.dart'; -//import 'package:json_god/json_god.dart' as god; - -@deprecated -class CustomMapService extends Service { - final List _items = []; - - Iterable tailor(Iterable items, Map? params) { - if (params == null) return items; - - var r = items; - - if (params['query'] is Map) { - var query = params['query'] as Map; - - for (var key in query.keys) { - r = r.where((m) => m[key] == query[key]); - } - } - - return r; - } - - @override - Future> index([params]) async => tailor(_items, params).toList(); - - @override - Future read(id, [Map? params]) async { - return tailor(_items, params).firstWhere((m) => m['id'] == id, - orElse: (() => throw AngelHttpException.notFound())); - } - - @override - Future create(data, [params]) async { - var d = data is Map ? data : (jsonDecode(data as String) as Map?)!; - d['id'] = _items.length.toString(); - _items.add(d); - return d; - } - - @override - Future remove(id, [params]) async { - if (id == null) _items.clear(); - } -} - -class Author { - String? id, name; - - Author({this.id, this.name}); - - Map toJson() => {'id': id, 'name': name}; -} - -class Book { - String? authorId, title; - - Book({this.authorId, this.title}); - - Map toJson() => {'authorId': authorId, 'title': title}; -} - -class Chapter { - String? bookId, title; - int? pageCount; - - Chapter({this.bookId, this.title, this.pageCount}); -} diff --git a/archived_packages/relations/test/has_many_test.dart b/archived_packages/relations/test/has_many_test.dart deleted file mode 100644 index 0796d04e..00000000 --- a/archived_packages/relations/test/has_many_test.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:angel_framework/angel_framework.dart'; -//import 'package:angel_relations/angel_relations.dart' as relations; -import 'package:angel_seeder/angel_seeder.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - late Angel app; - - setUp(() async { - app = Angel()..use('/authors', MapService())..use('/books', MapService()); - - await app.configure(seed( - 'authors', - SeederConfiguration( - count: 10, - template: {'name': (Faker faker) => faker.person.name()}, - callback: (Map author, seed) { - return seed( - 'books', - SeederConfiguration(delete: false, count: 10, template: { - 'authorId': author['id'], - 'title': (Faker faker) => - 'I love to eat ${faker.food.dish()}' - })); - }))); - - // TODO: Missing afterAll method - // app - // .findService('authors') - // .afterAll(relations.hasMany('books', foreignKey: 'authorId')); - }); - - test('index', () async { - var authors = await app.findService('authors')!.index(); - print(authors); - - expect(authors, allOf(isList, isNotEmpty)); - - for (var author in authors.whereType()) { - expect(author.keys, contains('books')); - - var books = author['books'] as List; - - for (var book in books) { - expect(book['authorId'], equals(author['id'])); - } - } - }); - - test('create', () async { - var tolstoy = await app - .findService('authors')! - .create(Author(name: 'Leo Tolstoy').toJson()); - - print(tolstoy); - expect(tolstoy.keys, contains('books')); - expect(tolstoy['books'], allOf(isList, isEmpty)); - }); -} diff --git a/archived_packages/relations/test/has_one_test.dart b/archived_packages/relations/test/has_one_test.dart deleted file mode 100644 index d7535f40..00000000 --- a/archived_packages/relations/test/has_one_test.dart +++ /dev/null @@ -1,57 +0,0 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_seeder/angel_seeder.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - late Angel app; - - setUp(() async { - app = Angel()..use('/authors', MapService())..use('/books', MapService()); - - await app.configure(seed( - 'authors', - SeederConfiguration( - count: 10, - template: {'name': (Faker faker) => faker.person.name()}, - callback: (Map author, seed) { - return seed( - 'books', - SeederConfiguration(delete: false, count: 10, template: { - 'authorId': author['id'], - 'title': (Faker faker) => - 'I love to eat ${faker.food.dish()}' - })); - }))); - - // TODO: Missing afterAll method - // app.findService('authors').afterAll( - // relations.hasOne('books', as: 'book', foreignKey: 'authorId')); - }); - - test('index', () async { - var authors = await app.findService('authors')!.index(); - print(authors); - - expect(authors, allOf(isList, isNotEmpty)); - - for (var author in authors.whereType()) { - expect(author.keys, contains('book')); - - var book = author['book'] as Map; - print('Author: $author'); - print('Book: $book'); - expect(book['authorId'], equals(author['id'])); - } - }); - - test('create', () async { - var tolstoy = await app - .findService('authors')! - .create(Author(name: 'Leo Tolstoy').toJson()); - - print(tolstoy); - expect(tolstoy.keys, contains('book')); - expect(tolstoy['book'], isNull); - }); -} diff --git a/archived_packages/rethink.zip b/archived_packages/rethink.zip new file mode 100644 index 00000000..a64022a0 Binary files /dev/null and b/archived_packages/rethink.zip differ diff --git a/archived_packages/rethink/.gitignore b/archived_packages/rethink/.gitignore deleted file mode 100644 index 20880a05..00000000 --- a/archived_packages/rethink/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.buildlog -.packages -.project -.pub/ -build/ -**/packages/ - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc -doc/api/ - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -pubspec.lock - -rethinkdb_data/ -.idea -.dart_tool \ No newline at end of file diff --git a/archived_packages/rethink/.travis.yml b/archived_packages/rethink/.travis.yml deleted file mode 100644 index d8efdb66..00000000 --- a/archived_packages/rethink/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: dart -addons: - rethinkdb: '2.3' -before_script: 'dart test/bootstrap.dart' \ No newline at end of file diff --git a/archived_packages/rethink/AUTHORS.md b/archived_packages/rethink/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/archived_packages/rethink/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - Thomas is the current maintainer of the code base. He has refactored and migrated the - code base to support NNBD. - -* __[Tobe O](thosakwe@gmail.com)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/archived_packages/rethink/CHANGELOG.md b/archived_packages/rethink/CHANGELOG.md deleted file mode 100644 index 98b9fed6..00000000 --- a/archived_packages/rethink/CHANGELOG.md +++ /dev/null @@ -1,10 +0,0 @@ -# Change Log - -## 2.0.0 - -* Migrated to support Dart >= 2.12 NNBD - -## 1.1.0 - -* Moved to `package:rethinkdb_driver` -* Fixed references to old hooked event names diff --git a/archived_packages/rethink/LICENSE b/archived_packages/rethink/LICENSE deleted file mode 100644 index df5e0635..00000000 --- a/archived_packages/rethink/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2021, dukefirehawk.com -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/archived_packages/rethink/README.md b/archived_packages/rethink/README.md deleted file mode 100644 index d899a0ff..00000000 --- a/archived_packages/rethink/README.md +++ /dev/null @@ -1,87 +0,0 @@ -# rethink -[![version 1.0.7](https://img.shields.io/badge/pub-1.0.7-brightgreen.svg)](https://pub.dartlang.org/packages/angel_rethink) -[![build status](https://travis-ci.org/angel-dart/rethink.svg?branch=master)](https://travis-ci.org/angel-dart/rethink) - -RethinkDB-enabled services for the Angel framework. - -# Installation -Add the following to your `pubspec.yaml`: - -```yaml -dependencies: - angel_rethink: ^1.0.0 -``` - -`package:rethinkdb_driver2` will be installed as well. - -# Usage -This library exposes one class: `RethinkService`. By default, these services will even -listen to [changefeeds](https://www.rethinkdb.com/docs/changefeeds/ruby/) from the database, -which makes them very suitable for WebSocket use. - -However, only `CREATED`, `UPDATED` and `REMOVED` events will be fired. This is technically not -a problem, as it lowers the numbers of events you have to handle on the client side. ;) - -## Model -`Model` is class with no real functionality; however, it represents a basic document, and your services should host inherited classes. -Other Angel service providers host `Model` as well, so you will easily be able to modify your application if you ever switch databases. - -```dart -class User extends Model { - String username; - String password; -} - -main() async { - var r = new RethinkDb(); - var conn = await r.connect(); - - app.use('/api/users', new RethinkService(conn, r.table('users'))); - - // Add type de/serialization if you want - app.use('/api/users', new TypedService(new RethinkService(conn, r.table('users')))); - - // You don't have to even use a table... - app.use('/api/pro_users', new RethinkService(conn, r.table('users').filter({'membership': 'pro'}))); - - app.service('api/users').afterCreated.listen((event) { - print("New user: ${event.result}"); - }); -} -``` - -## RethinkService -This class interacts with a `Query` (usually a table) and serializes data to and from Maps. - -## RethinkTypedService -Does the same as above, but serializes to and from a target class using `package:json_god` and its support for reflection. - -## Querying -You can query these services as follows: - - /path/to/service?foo=bar - -The above will query the database to find records where 'foo' equals 'bar'. - -The former will sort result in ascending order of creation, and so will the latter. - -You can use advanced queries: - -```dart -// Pass an actual query... -service.index({'query': r.table('foo').filter(...)}); - -// Or, a function that creates a query from a table... -service.index({'query': (table) => table.getAll('foo')}); - -// Or, a Map, which will be transformed into a `filter` query: -service.index({'query': {'foo': 'bar', 'baz': 'quux'}}); -``` - -You can also apply sorting by adding a `reql` parameter on the server-side. - -```dart -service.index({'reql': (query) => query.sort(...)}); -``` - -See the tests for more usage examples. diff --git a/archived_packages/rethink/analysis_options.yaml b/archived_packages/rethink/analysis_options.yaml deleted file mode 100644 index ea2c9e94..00000000 --- a/archived_packages/rethink/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml \ No newline at end of file diff --git a/archived_packages/rethink/lib/angel_rethink.dart b/archived_packages/rethink/lib/angel_rethink.dart deleted file mode 100644 index e0f27f42..00000000 --- a/archived_packages/rethink/lib/angel_rethink.dart +++ /dev/null @@ -1 +0,0 @@ -export 'src/rethink_service.dart'; \ No newline at end of file diff --git a/archived_packages/rethink/lib/src/rethink_service.dart b/archived_packages/rethink/lib/src/rethink_service.dart deleted file mode 100644 index 3ed955ee..00000000 --- a/archived_packages/rethink/lib/src/rethink_service.dart +++ /dev/null @@ -1,251 +0,0 @@ -import 'dart:async'; -//import 'dart:io'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:json_god/json_god.dart' as god; -import 'package:rethinkdb_dart/rethinkdb_dart.dart'; - -// Extends a RethinkDB query. -typedef QueryCallback = RqlQuery Function(RqlQuery query); - -/// Queries a single RethinkDB table or query. -class RethinkService extends Service { - /// If set to `true`, clients can remove all items by passing a `null` `id` to `remove`. - /// - /// `false` by default. - final bool allowRemoveAll; - - /// If set to `true`, parameters in `req.query` are applied to the database query. - final bool allowQuery; - - final bool debug; - - /// If set to `true`, then a HookedService mounted over this instance - /// will fire events when RethinkDB pushes events. - /// - /// Good for scaling. ;) - final bool listenForChanges; - - final Connection connection; - - /// Doesn't actually have to be a table, just a RethinkDB query. - /// - /// However, a table is the most common usecase. - final RqlQuery table; - - RethinkService(this.connection, this.table, - {this.allowRemoveAll = false, - this.allowQuery = true, - this.debug = false, - this.listenForChanges = true}) - : super(); - - RqlQuery buildQuery(RqlQuery initialQuery, Map params) { - if (params != null) { - params['broadcast'] = params.containsKey('broadcast') - ? params['broadcast'] - : (listenForChanges != true); - } - - var q = _getQueryInner(initialQuery, params); - - if (params?.containsKey('reql') == true && - params['reql'] is QueryCallback) { - q = params['reql'](q) as RqlQuery; - } - - return q ?? initialQuery; - } - - RqlQuery _getQueryInner(RqlQuery query, Map params) { - if (params == null || !params.containsKey('query')) { - return query; - } else { - if (params['query'] is RqlQuery) { - return params['query'] as RqlQuery; - } else if (params['query'] is QueryCallback) { - return params['query'](table) as RqlQuery; - } else if (params['query'] is! Map || allowQuery != true) { - return query; - } else { - var q = params['query'] as Map; - return q.keys.fold(query, (out, key) { - var val = q[key]; - - if (val is RequestContext || - val is ResponseContext || - key == 'provider' || - val is Providers) { - return out; - } else { - return out.filter({key.toString(): val}); - } - }); - } - } - } - - Future _sendQuery(RqlQuery query) async { - var result = await query.run(connection); - - if (result is Cursor) { - return await result.toList(); - } else if (result is Map && result['generated_keys'] is List) { - if (result['generated_keys'].length == 1) { - return await read(result['generated_keys'].first); - } - //return await Future.wait(result['generated_keys'].map(read)); - return await result['generated_keys'].map(read); - } else { - return result; - } - } - - dynamic _serialize(data) { - if (data is Map) { - return data; - } else if (data is Iterable) { - return data.map(_serialize).toList(); - } else { - return god.serializeObject(data); - } - } - - dynamic _squeeze(data) { - if (data is Map) { - return data.keys.fold({}, (map, k) => map..[k.toString()] = data[k]); - } else if (data is Iterable) { - return data.map(_squeeze).toList(); - } else { - return data; - } - } - - @override - void onHooked(HookedService hookedService) { - if (listenForChanges == true) { - listenToQuery(table, hookedService); - } - } - - Future listenToQuery(RqlQuery query, HookedService hookedService) async { - var feed = - await query.changes({'include_types': true}).run(connection) as Feed; - - feed.listen((Map event) { - var type = event['type']?.toString(); - var newVal = event['new_val'], oldVal = event['old_val']; - - if (type == 'add') { - // Create - hookedService.fireEvent( - hookedService.afterCreated, - HookedServiceEvent( - true, null, null, this, HookedServiceEvent.created, - result: newVal)); - } else if (type == 'change') { - // Update - hookedService.fireEvent( - hookedService.afterCreated, - HookedServiceEvent( - true, null, null, this, HookedServiceEvent.updated, - result: newVal, id: oldVal['id'], data: newVal)); - } else if (type == 'remove') { - // Remove - hookedService.fireEvent( - hookedService.afterCreated, - HookedServiceEvent( - true, null, null, this, HookedServiceEvent.removed, - result: oldVal, id: oldVal['id'])); - } - }); - } - - // TODO: Invalid override method -/* - @override - Future index([Map params]) async { - var query = buildQuery(table, params); - return await _sendQuery(query); - } -*/ - @override - Future read(id, [Map params]) async { - var query = buildQuery(table.get(id?.toString()), params); - var found = await _sendQuery(query); - //print('Found for $id: $found'); - - if (found == null) { - throw AngelHttpException.notFound(message: 'No record found for ID $id'); - } else { - return found; - } - } - - @override - Future create(data, [Map params]) async { - if (table is! Table) throw AngelHttpException.methodNotAllowed(); - - var d = _serialize(data); - var q = table as Table; - var query = buildQuery(q.insert(_squeeze(d)), params); - return await _sendQuery(query); - } - - @override - Future modify(id, data, [Map params]) async { - var d = _serialize(data); - - if (d is Map && d.containsKey('id')) { - try { - await read(d['id'], params); - } on AngelHttpException catch (e) { - if (e.statusCode == 404) { - return await create(data, params); - } else { - rethrow; - } - } - } - - var query = buildQuery(table.get(id?.toString()), params).update(d); - await _sendQuery(query); - return await read(id, params); - } - - @override - Future update(id, data, [Map params]) async { - var d = _serialize(data); - - if (d is Map && d.containsKey('id')) { - try { - await read(d['id'], params); - } on AngelHttpException catch (e) { - if (e.statusCode == 404) { - return await create(data, params); - } else { - rethrow; - } - } - } - - if (d is Map && !d.containsKey('id')) d['id'] = id.toString(); - var query = buildQuery(table.get(id?.toString()), params).replace(d); - await _sendQuery(query); - return await read(id, params); - } - - @override - Future remove(id, [Map params]) async { - if (id == null || - id == 'null' && - (allowRemoveAll == true || - params?.containsKey('provider') != true)) { - return await _sendQuery(table.delete()); - } else { - var prior = await read(id, params); - var query = buildQuery(table.get(id), params).delete(); - await _sendQuery(query); - return prior; - } - } -} diff --git a/archived_packages/rethink/pubspec.yaml b/archived_packages/rethink/pubspec.yaml deleted file mode 100644 index f53b52ad..00000000 --- a/archived_packages/rethink/pubspec.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: angel_rethink -version: 2.0.0 -description: RethinkDB-enabled services for the Angel framework. -publish_to: none -environment: - sdk: ">=2.10.0 <3.0.0" -homepage: https://github.com/angel-dart/rethink -dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework - json_god: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/json_god - rethinkdb_dart: ^2.3.2+6 -dev_dependencies: - angel_client: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/client - angel_test: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/test - logging: ^1.0.0 - test: ^1.15.7 - lints: ^1.0.0 -dependency_overrides: - crypto: ^3.0.0 \ No newline at end of file diff --git a/archived_packages/rethink/test/README.md b/archived_packages/rethink/test/README.md deleted file mode 100644 index 2b9eed87..00000000 --- a/archived_packages/rethink/test/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Tests - -The tests expect you to have installed RethinkDB. You must have a `test` database -available, and a server ready at the default port. - -Also, the tests expect a table named `todos`. \ No newline at end of file diff --git a/archived_packages/rethink/test/bootstrap.dart b/archived_packages/rethink/test/bootstrap.dart deleted file mode 100644 index 8782d8ab..00000000 --- a/archived_packages/rethink/test/bootstrap.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'dart:io'; -import 'package:rethinkdb_dart/rethinkdb_dart.dart'; - -void main() async { - var r = Rethinkdb(); - await r.connect().then((conn) { - r.tableCreate('todos').run(conn); - print('Done'); - exit(0); - }); -} diff --git a/archived_packages/rethink/test/common.dart b/archived_packages/rethink/test/common.dart deleted file mode 100644 index ba2e5f4b..00000000 --- a/archived_packages/rethink/test/common.dart +++ /dev/null @@ -1,10 +0,0 @@ -class Todo { - String title; - bool completed; - - Todo({this.title, this.completed = false}); - - Map toJson() { - return {'title': title, 'completed': completed == true}; - } -} diff --git a/archived_packages/rethink/test/generic_test.dart b/archived_packages/rethink/test/generic_test.dart deleted file mode 100644 index b2da9856..00000000 --- a/archived_packages/rethink/test/generic_test.dart +++ /dev/null @@ -1,85 +0,0 @@ -import 'package:angel_client/angel_client.dart' as c; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_rethink/angel_rethink.dart'; -import 'package:angel_test/angel_test.dart'; -import 'package:logging/logging.dart'; -import 'package:rethinkdb_dart/rethinkdb_dart.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - Angel app; - TestClient client; - Rethinkdb r; - c.Service todoService; - - setUp(() async { - r = Rethinkdb(); - var conn = await r.connect(); - - app = Angel(); - app.use('/todos', RethinkService(conn, r.table('todos'))); - - app.errorHandler = (e, req, res) async { - print('Whoops: $e'); - }; - - app.logger = Logger.detached('angel')..onRecord.listen(print); - - client = await connectTo(app); - todoService = client.service('todos'); - }); - - tearDown(() => client.close()); - - test('index', () async { - var result = await todoService.index(); - print('Response: $result'); - expect(result, isList); - }); - - test('create+read', () async { - var todo = Todo(title: 'Clean your room'); - var creation = await todoService.create(todo.toJson()); - print('Creation: $creation'); - - var id = creation['id']; - var result = await todoService.read(id); - - print('Response: $result'); - expect(result, isMap); - expect(result['id'], equals(id)); - expect(result['title'], equals(todo.title)); - expect(result['completed'], equals(todo.completed)); - }); - - test('modify', () async { - var todo = Todo(title: 'Clean your room'); - var creation = await todoService.create(todo.toJson()); - print('Creation: $creation'); - - var id = creation['id']; - var result = await todoService.modify(id, {'title': 'Eat healthy'}); - - print('Response: $result'); - expect(result, isMap); - expect(result['id'], equals(id)); - expect(result['title'], equals('Eat healthy')); - expect(result['completed'], equals(todo.completed)); - }); - - test('remove', () async { - var todo = Todo(title: 'Clean your room'); - var creation = await todoService.create(todo.toJson()); - print('Creation: $creation'); - - var id = creation['id']; - var result = await todoService.remove(id); - - print('Response: $result'); - expect(result, isMap); - expect(result['id'], equals(id)); - expect(result['title'], equals(todo.title)); - expect(result['completed'], equals(todo.completed)); - }); -} diff --git a/archived_packages/seeder.zip b/archived_packages/seeder.zip new file mode 100644 index 00000000..15a423e5 Binary files /dev/null and b/archived_packages/seeder.zip differ diff --git a/archived_packages/seeder/.gitignore b/archived_packages/seeder/.gitignore deleted file mode 100644 index 7c280441..00000000 --- a/archived_packages/seeder/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.buildlog -.packages -.project -.pub/ -build/ -**/packages/ - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc -doc/api/ - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -pubspec.lock diff --git a/archived_packages/seeder/.travis.yml b/archived_packages/seeder/.travis.yml deleted file mode 100644 index de2210c9..00000000 --- a/archived_packages/seeder/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: dart \ No newline at end of file diff --git a/archived_packages/seeder/AUTHORS.md b/archived_packages/seeder/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/archived_packages/seeder/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - Thomas is the current maintainer of the code base. He has refactored and migrated the - code base to support NNBD. - -* __[Tobe O](thosakwe@gmail.com)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/archived_packages/seeder/CHANGELOG.md b/archived_packages/seeder/CHANGELOG.md deleted file mode 100644 index 9a5d3f9b..00000000 --- a/archived_packages/seeder/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Change Log - -## 2.0.0 - -* Migrated to support Dart >= 2.12 NNBD - -## 1.0.0 - -* Initial checkin diff --git a/archived_packages/seeder/LICENSE b/archived_packages/seeder/LICENSE deleted file mode 100644 index df5e0635..00000000 --- a/archived_packages/seeder/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2021, dukefirehawk.com -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/archived_packages/seeder/README.md b/archived_packages/seeder/README.md deleted file mode 100644 index 4362bf9c..00000000 --- a/archived_packages/seeder/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# angel_seeder - -[![version 1.0.](https://img.shields.io/pub/v/angel_seeder.svg)](https://pub.dartlang.org/packages/angel_seeder) -[![build status](https://travis-ci.org/angel-dart/seeder.svg?branch=master)](https://travis-ci.org/angel-dart/seeder) - -Straightforward data seeder for Angel services. -This is an almost exact port of [feathers-seeder](https://github.com/thosakwe/feathers-seeder), -so its documentation should almost exactly match up here. -Fortunately, I was also the one who made `feathers-seeder`, so if you ever need assistance, -file an issue. - -# Example -```dart -var app = new Angel()..use('/todos', new TodoService()); - -await app.configure(seed( - 'todos', - new SeederConfiguration(delete: false, count: 10, template: { - 'text': (Faker faker) => 'Clean your room, ${faker.person.name()}!', - 'completed': false - }))); -``` - -**NOTE**: Don't *await* seeding at application startup; that's too slow. -Instead, run it asynchronously. \ No newline at end of file diff --git a/archived_packages/seeder/analysis_options.yaml b/archived_packages/seeder/analysis_options.yaml deleted file mode 100644 index ea2c9e94..00000000 --- a/archived_packages/seeder/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml \ No newline at end of file diff --git a/archived_packages/seeder/lib/angel_seeder.dart b/archived_packages/seeder/lib/angel_seeder.dart deleted file mode 100644 index 87d14e50..00000000 --- a/archived_packages/seeder/lib/angel_seeder.dart +++ /dev/null @@ -1,141 +0,0 @@ -import 'dart:math'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:faker/faker.dart'; -export 'package:faker/faker.dart'; - -/// Generates data using a [Faker]. -typedef FakerCallback = Function(Faker faker); - -/// Used to seed nested objects. -typedef SeederCallback = Function(T created, - Function(Pattern path, SeederConfiguration configuration, {bool? verbose})); - -/// Seeds the given service in development. -AngelConfigurer seed( - Pattern servicePath, - SeederConfiguration configuration, { - bool verbose = false, -}) { - return (Angel app) async { - if (configuration.runInProduction != true) return; - - if (!app.services.containsKey(servicePath)) { - throw ArgumentError( - "App does not contain a service at path '$servicePath'."); - } - - if (configuration.disabled == true) { - print("Service '$servicePath' will not be seeded."); - return; - } - - var service = app.findService(servicePath); - var faker = Faker(); - - Map _buildTemplate(Map data) { - return data.keys.fold({}, (map, key) { - var value = data[key]; - - if (value is FakerCallback) { - return map..[key] = value(faker); - } else if (value is Function) { - return map..[key] = value(); - } else if (value is Map) { - return map..[key] = _buildTemplate(value); - } else { - return map..[key] = value; - } - }); - } - - Future Function(SeederConfiguration configuration) _buildSeeder( - Service? service, - {bool? verbose}) { - return (SeederConfiguration configuration) async { - if (configuration.delete == true) await service!.remove(null); - - var count = configuration.count; - var rnd = Random(); - if (count < 1) count = 1; - - for (var i = 0; i < count; i++) { - Future _gen(template) async { - var data = template; - - if (data is Map) { - data = _buildTemplate(data); - } else if (data is Faker) { - data = template(faker); - } - - var params = {}..addAll(configuration.params); - var result = await service!.create(data, params); - - if (configuration.callback != null) { - await configuration.callback!(result, - (Pattern path, SeederConfiguration configuration, - {bool? verbose}) { - return _buildSeeder(app.findService(path), - verbose: verbose == true)(configuration); - }); - } - } - - if (configuration.template != null) { - await _gen(configuration.template); - } else if (configuration.templates.isNotEmpty == true) { - var template = configuration.templates - .elementAt(rnd.nextInt(configuration.templates.length)); - await _gen(template); - } else { - throw ArgumentError( - 'Configuration for service \'$servicePath\' must define at least one template.'); - } - } - - if (verbose == true) { - print('Created $count object(s) in service \'$servicePath\'.'); - } - }; - } - - await _buildSeeder(service, verbose: verbose == true)(configuration); - }; -} - -/// Configures the seeder. -class SeederConfiguration { - /// Optional callback on creation. - final SeederCallback? callback; - - /// Number of objects to seed. - final int count; - - /// If `true`, all records in the service are deleted before seeding. - final bool delete; - - /// If `true`, seeding will not occur. - final bool disabled; - - /// Optional service parameters to be passed. - final Map params; - - /// Unless this is `true`, the seeder will not run in production. - final bool runInProduction; - - /// A data template to build from. - final template; - - /// A set of templates to choose from. - final Iterable templates; - - SeederConfiguration( - {this.callback, - this.count = 1, - this.delete = true, - this.disabled = false, - this.params = const {}, - this.runInProduction = false, - this.template, - this.templates = const []}); -} diff --git a/archived_packages/seeder/pubspec.yaml b/archived_packages/seeder/pubspec.yaml deleted file mode 100644 index 33462335..00000000 --- a/archived_packages/seeder/pubspec.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: angel_seeder -version: 2.0.0 -description: Straightforward data seeder for Angel services. -publish_to: none -environment: - sdk: '>=2.12.0 <3.0.0' -homepage: https://github.com/angel-dart/seeder -dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework - faker: ^2.0.0 -dev_dependencies: - test: ^1.17.8 - lints: ^1.0.0 diff --git a/archived_packages/seeder/test/all_test.dart b/archived_packages/seeder/test/all_test.dart deleted file mode 100644 index 8d6f4af5..00000000 --- a/archived_packages/seeder/test/all_test.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'dart:async'; - -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_container/mirrors.dart'; -import 'package:angel_seeder/angel_seeder.dart'; -import 'package:test/test.dart'; - -void main() { - test('create one', () async { - var app = Angel(reflector: MirrorsReflector()) - ..use('/todos', TodoService()); - - await app.configure(seed( - 'todos', - SeederConfiguration(delete: false, count: 10, template: { - 'text': (Faker faker) => 'Clean your room, ${faker.person.name()}!', - 'completed': false - }))); - - var todos = await app.findService('todos')!.index(); - print('Todos: \n${todos.map((todo) => " - $todo").join("\n")}'); - - expect(todos, isList); - expect(todos, hasLength(10)); - }); -} - -class TodoService extends Service { - final List todos = []; - - @override - Future> index([params]) => myData(); - - Future> myData() { - var completer = Completer>(); - completer.complete(todos); - return completer.future; - } - - @override - Future create(data, [params]) async { - if (data is Todo) { - todos.add(data..id = todos.length.toString()); - return data; - } else if (data is Map) { - todos.add(Todo.fromJson(data)..id = todos.length.toString()); - return data; - } else { - throw AngelHttpException.badRequest(); - } - } -} - -class Todo extends Model { - final String? text; - final bool? completed; - - Todo({String? id, this.text, this.completed = false}) { - this.id = id; - } - - factory Todo.fromJson(Map data) => Todo( - id: data['id'] as String?, - text: data['text'] as String?, - completed: data['completed'] as bool?); - - @override - String toString() => '${completed! ? "Complete" : "Incomplete"}: $text'; -} diff --git a/archived_packages/typed_service.zip b/archived_packages/typed_service.zip new file mode 100644 index 00000000..a67b86d0 Binary files /dev/null and b/archived_packages/typed_service.zip differ diff --git a/archived_packages/typed_service/.gitignore b/archived_packages/typed_service/.gitignore deleted file mode 100644 index 7bf00e82..00000000 --- a/archived_packages/typed_service/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# See https://www.dartlang.org/guides/libraries/private-files - -# Files and directories created by pub -.dart_tool/ -.packages -.pub/ -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ diff --git a/archived_packages/typed_service/AUTHORS.md b/archived_packages/typed_service/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/archived_packages/typed_service/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - Thomas is the current maintainer of the code base. He has refactored and migrated the - code base to support NNBD. - -* __[Tobe O](thosakwe@gmail.com)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/archived_packages/typed_service/CHANGELOG.md b/archived_packages/typed_service/CHANGELOG.md deleted file mode 100644 index ea021631..00000000 --- a/archived_packages/typed_service/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# Change Log - -## 2.0.0 - -* Migrated to support Dart >= 2.12 NNBD - -## 1.0.1 - -* Explicitly extend `Service`. -* Override `readData`. -* Use `Service>` for `inner`, instead of just -`Service`. - -## 1.0.0 - -* Initial version. diff --git a/archived_packages/typed_service/LICENSE b/archived_packages/typed_service/LICENSE deleted file mode 100644 index df5e0635..00000000 --- a/archived_packages/typed_service/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2021, dukefirehawk.com -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/archived_packages/typed_service/README.md b/archived_packages/typed_service/README.md deleted file mode 100644 index 87220849..00000000 --- a/archived_packages/typed_service/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# typed_service -Angel services that use reflection (via mirrors or codegen) to (de)serialize PODO's. -Useful for quick prototypes. - -Typically, [`package:angel_serialize`](https://github.com/angel-dart/serialize) -is recommended. - -## Brief Example -```dart -main() async { - var app = Angel(); - var http = AngelHttp(app); - var service = TypedService(MapService()); - hierarchicalLoggingEnabled = true; - app.use('/api/todos', service); - - app - ..serializer = god.serialize - ..logger = Logger.detached('typed_service') - ..logger.onRecord.listen((rec) { - print(rec); - if (rec.error != null) print(rec.error); - if (rec.stackTrace != null) print(rec.stackTrace); - }); - - await http.startServer('127.0.0.1', 3000); - print('Listening at ${http.uri}'); -} -``` \ No newline at end of file diff --git a/archived_packages/typed_service/analysis_options.yaml b/archived_packages/typed_service/analysis_options.yaml deleted file mode 100644 index ea2c9e94..00000000 --- a/archived_packages/typed_service/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml \ No newline at end of file diff --git a/archived_packages/typed_service/example/README.md b/archived_packages/typed_service/example/README.md deleted file mode 100644 index 4e35b7db..00000000 --- a/archived_packages/typed_service/example/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Command: - -```bash -curl -X POST -d '@example/data.json' -H 'content-type: application/json' http://localhost:3000/api/todos; echo -``` \ No newline at end of file diff --git a/archived_packages/typed_service/example/data.json b/archived_packages/typed_service/example/data.json deleted file mode 100644 index e7a12b94..00000000 --- a/archived_packages/typed_service/example/data.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "id": "0", - "createdAt": null, - "updatedAt": null, - "idAsInt": null, - "text": "Yes", - "completed": false, - "created_at": "2019-04-26T09:51:27.494884", - "updated_at": "2019-04-26T09:51:27.494884" - }, - { - "id": "1", - "createdAt": null, - "updatedAt": null, - "idAsInt": null, - "text": "nOPE", - "completed": false, - "created_at": "2019-04-26T09:51:37.847741", - "updated_at": "2019-04-26T09:51:37.847741" - } -] \ No newline at end of file diff --git a/archived_packages/typed_service/example/main.dart b/archived_packages/typed_service/example/main.dart deleted file mode 100644 index b4203e3d..00000000 --- a/archived_packages/typed_service/example/main.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'dart:io'; -import 'package:angel_file_service/angel_file_service.dart'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -import 'package:angel_typed_service/angel_typed_service.dart'; -import 'package:file/local.dart'; -import 'package:json_god/json_god.dart' as god; -import 'package:logging/logging.dart'; - -void main() async { - var app = Angel(); - var http = AngelHttp(app); - var fs = LocalFileSystem(); - var exampleDir = fs.file(Platform.script).parent; - var dataJson = exampleDir.childFile('data.json'); - var service = TypedService(JsonFileService(dataJson)); - hierarchicalLoggingEnabled = true; - app.use('/api/todos', service); - - app - ..serializer = god.serialize - ..logger = Logger.detached('typed_service') - ..logger!.onRecord.listen((rec) { - print(rec); - if (rec.error != null) print(rec.error); - if (rec.stackTrace != null) print(rec.stackTrace); - }); - - await http.startServer('127.0.0.1', 3000); - print('Listening at ${http.uri}'); -} - -class Todo extends Model { - String? text; - bool? completed; - - @override - DateTime? createdAt, updatedAt; - - Todo({String? id, this.text, this.completed, this.createdAt, this.updatedAt}) - : super(id: id); -} diff --git a/archived_packages/typed_service/lib/angel_typed_service.dart b/archived_packages/typed_service/lib/angel_typed_service.dart deleted file mode 100644 index f78924bf..00000000 --- a/archived_packages/typed_service/lib/angel_typed_service.dart +++ /dev/null @@ -1,100 +0,0 @@ -import 'dart:async'; -import 'dart:mirrors'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:json_god/json_god.dart' as god; - -/// An Angel service that uses reflection to (de)serialize Dart objects. -class TypedService extends Service { - /// The inner service. - final Service> inner; - - TypedService(this.inner) : super() { - if (!reflectType(T).isAssignableTo(reflectType(Model))) { - throw Exception( - 'If you specify a type for TypedService, it must extend Model.'); - } - } - - @override - FutureOr? Function(RequestContext, ResponseContext) get readData => - _readData; - - T? _readData(RequestContext req, ResponseContext res) => - deserialize(req.bodyAsMap); - - /// Attempts to deserialize [x] into an instance of [T]. - T? deserialize(x) { - // print('DESERIALIZE: $x (${x.runtimeType})'); - if (x is T) { - return x; - } else if (x is Map) { - var data = x.keys.fold({}, (dynamic map, key) { - var value = x[key]; - - if ((key == 'createdAt' || - key == 'updatedAt' || - key == 'created_at' || - key == 'updated_at') && - value is String) { - return map..[key] = DateTime.parse(value); - } else { - return map..[key] = value; - } - }); - - var result = god.deserializeDatum(data, outputType: T); - - if (data['createdAt'] is DateTime) { - result.createdAt = data['createdAt'] as DateTime?; - } else if (data['created_at'] is DateTime) { - result.createdAt = data['created_at'] as DateTime?; - } - - if (data['updatedAt'] is DateTime) { - result.updatedAt = data['updatedAt'] as DateTime?; - } else if (data['updated_at'] is DateTime) { - result.updatedAt = data['updated_at'] as DateTime?; - } - - // print('x: $x\nresult: $result'); - return result as T?; - } else { - throw ArgumentError('Cannot convert $x to $T'); - } - } - - /// Serializes [x] into a [Map]. - Map serialize(x) { - if (x is Model) { - return (god.serializeObject(x) as Map).cast(); - } else if (x is Map) { - return x.cast(); - } else { - throw ArgumentError('Cannot serialize ${x.runtimeType}'); - } - } - - @override - Future> index([Map? params]) => - inner.index(params).then((it) => it.map(deserialize).toList()); - - @override - Future create(data, [Map? params]) => - inner.create(serialize(data), params).then(deserialize as FutureOr Function(Map)); - - @override - Future read(Id id, [Map? params]) => - inner.read(id, params).then(deserialize as FutureOr Function(Map)); - - @override - Future modify(Id id, T? data, [Map? params]) => - inner.modify(id, serialize(data), params).then(deserialize as FutureOr Function(Map)); - - @override - Future update(Id id, T? data, [Map? params]) => - inner.update(id, serialize(data), params).then(deserialize as FutureOr Function(Map)); - - @override - Future remove(Id id, [Map? params]) => - inner.remove(id, params).then(deserialize as FutureOr Function(Map)); -} diff --git a/archived_packages/typed_service/pubspec.yaml b/archived_packages/typed_service/pubspec.yaml deleted file mode 100644 index a1e7674d..00000000 --- a/archived_packages/typed_service/pubspec.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: angel_typed_service -version: 2.0.0 -description: Angel services that use reflection to (de)serialize Dart objects. -homepage: https://github.com/angel-dart/typed_service -publish_to: none -environment: - sdk: '>=2.12.0 <3.0.0' -dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework - json_god: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/json_god - -dev_dependencies: - angel_file_service: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/file_service - file: ^6.0.0 - logging: ^1.0.0 - lints: ^1.0.0 - test: ^1.15.7 \ No newline at end of file diff --git a/archived_packages/typed_service/test/typed_service_test.dart b/archived_packages/typed_service/test/typed_service_test.dart deleted file mode 100644 index 6e1b3acf..00000000 --- a/archived_packages/typed_service/test/typed_service_test.dart +++ /dev/null @@ -1,57 +0,0 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_typed_service/angel_typed_service.dart'; -import 'package:test/test.dart'; - -void main() { - var svc = TypedService(MapService()); - - test('force model', () { - expect(() => TypedService(MapService()), throwsException); - }); - - test('serialize', () { - expect(svc.serialize({'foo': 'bar'}), {'foo': 'bar'}); - expect(() => svc.serialize(2), throwsArgumentError); - var now = DateTime.now(); - var t = Todo( - id: '3', text: 'a', completed: false, createdAt: now, updatedAt: now); - var m = svc.serialize(t); - print(m); - expect(m..remove('_identityHashCode')..remove('idAsInt'), { - 'id': '3', - 'createdAt': now.toIso8601String(), - 'updatedAt': now.toIso8601String(), - 'text': 'a', - 'completed': false - }); - }); - - test('deserialize date', () { - var now = DateTime.now(); - var m = svc.deserialize({ - 'createdAt': now.toIso8601String(), - 'updatedAt': now.toIso8601String() - })!; - expect(m, const TypeMatcher()); - expect(m.createdAt!.millisecondsSinceEpoch, now.millisecondsSinceEpoch); - }); - - test('deserialize date w/ underscore', () { - var now = DateTime.now(); - var m = svc.deserialize({ - 'created_at': now.toIso8601String(), - 'updated_at': now.toIso8601String() - })!; - expect(m, const TypeMatcher()); - expect(m.createdAt!.millisecondsSinceEpoch, now.millisecondsSinceEpoch); - }); -} - -class Todo extends Model { - String? text; - bool? completed; - @override - DateTime? createdAt, updatedAt; - Todo({String? id, this.text, this.completed, this.createdAt, this.updatedAt}) - : super(id: id); -} diff --git a/archived_packages/wings.zip b/archived_packages/wings.zip new file mode 100644 index 00000000..8489890e Binary files /dev/null and b/archived_packages/wings.zip differ diff --git a/archived_packages/wings/.clang-format b/archived_packages/wings/.clang-format deleted file mode 100644 index d30c5da2..00000000 --- a/archived_packages/wings/.clang-format +++ /dev/null @@ -1,121 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: LLVM -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: MultiLine -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: true -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -IndentPPDirectives: None -IndentWidth: 2 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 8 -UseTab: Never -... - diff --git a/archived_packages/wings/.gitignore b/archived_packages/wings/.gitignore deleted file mode 100644 index f2aac56f..00000000 --- a/archived_packages/wings/.gitignore +++ /dev/null @@ -1,67 +0,0 @@ -# See https://www.dartlang.org/guides/libraries/private-files - -# Files and directories created by pub -.dart_tool/ -.packages -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -# Avoid committing generated Javascript files: -*.dart.js -*.info.json # Produced by the --dump-info flag. -*.js # When generated by dart2js. Don't specify *.js if your - # project includes source files written in JavaScript. -*.js_ -*.js.deps -*.js.map - -*.o -# *.dylib -*.a -# *.so -*.lib -*.obj - -.vscode/ -.idea/ -# Created by https://www.gitignore.io/api/cmake -# Edit at https://www.gitignore.io/?templates=cmake - -### CMake ### -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -_deps - -### CMake Patch ### -# External projects -*-prefix/ - -# End of https://www.gitignore.io/api/cmake - -# Created by https://www.gitignore.io/api/vagrant -# Edit at https://www.gitignore.io/?templates=vagrant - -### Vagrant ### -# General -.vagrant/ - -# Log files (if you are creating logs in debug mode, uncomment this) -# *.log - -### Vagrant Patch ### -*.box - -# End of https://www.gitignore.io/api/vagrant diff --git a/archived_packages/wings/.gitmodules b/archived_packages/wings/.gitmodules deleted file mode 100644 index 6b6d60b5..00000000 --- a/archived_packages/wings/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "cmake_dart_utils"] - path = cmake_dart_utils - url = https://github.com/thosakwe/cmake_dart_utils.git -[submodule "lib/src/http-parser"] - path = lib/src/http-parser - url = https://github.com/nodejs/http-parser.git diff --git a/archived_packages/wings/CMakeLists.txt b/archived_packages/wings/CMakeLists.txt deleted file mode 100644 index 4b4c1257..00000000 --- a/archived_packages/wings/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 3.0) -project(angel_wings) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_dart_utils/cmake") -find_package(Dart REQUIRED) -set(CMAKE_CXX_STANDARD 11) -add_subdirectory(lib/src) \ No newline at end of file diff --git a/archived_packages/wings/LICENSE b/archived_packages/wings/LICENSE deleted file mode 100644 index df5e0635..00000000 --- a/archived_packages/wings/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2021, dukefirehawk.com -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/archived_packages/wings/README.md b/archived_packages/wings/README.md deleted file mode 100644 index 4a80caa3..00000000 --- a/archived_packages/wings/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# wings -Native HTTP driver for Angel, for a nice speed boost. - -Not ready for production. - -## How does it work? -Typically, Angel uses the `AngelHttp` driver, which is wrapper over the `HttpServer` functionality in -`dart:io`, which in turns uses the `ServerSocket` and `Socket` functionality. This is great - Dart's standard -library comes with an HTTP server, which saves a lot of difficult in implementation. - -However, abstraction tends to come with a cost. Wings seeks to minimize abstraction entirely. Rather than -using the built-in Dart network stack, Wings' HTTP server is implemented in C++ as a Dart native extension, -and the `AngelWings` driver listens to events from the extension and converts them directly into -`RequestContext` objects, without any additional abstraction within. This reduces the amount of computation -performed on each request, and helps to minimize response latency. Sending data from the response buffer in plain -Dart surprisingly is the most expensive operation, as is revealed by the Observatory. - -By combining Dart's powerful VM with a native code server based on -[the same one used in Node.js](https://github.com/nodejs/http-parser), -`AngelWings` trims several milliseconds off every request, both saving resources and reducing -load times for high-traffic applications. - -## How can I use it? -The intended way to use `AngelWings` is via -[`package:build_native`](https://github.com/thosakwe/build_native); -however, the situation surrounding distributing native extensions is yet far from ideal, -so this package includes pre-built binaries out-of-the-box. - -Thanks to this, you can use it like any other Dart package, by installing it via Pub. - -## Brief example -Using `AngelWings` is almost identical to using `AngelHttp`; however, it does -not support SSL, and therefore should be placed behind a reverse proxy like `nginx` in production. - -```dart -main() async { - var app = new Angel(); - var wings = new AngelWings(app, shared: true, useZone: false); - - app.injectEncoders({'gzip': gzip.encoder, 'deflate': zlib.encoder}); - - app.get('/hello', 'Hello, native world! This is Angel WINGS.'); - - var fs = const LocalFileSystem(); - var vDir = new VirtualDirectory(app, fs, source: fs.directory('web')); - app.use(vDir.handleRequest); - - await wings.startServer('127.0.0.1', 3000); - print('Listening at http://${wings.address.address}:${wings.port}'); -} -``` \ No newline at end of file diff --git a/archived_packages/wings/Vagrantfile b/archived_packages/wings/Vagrantfile deleted file mode 100644 index 995ff4a3..00000000 --- a/archived_packages/wings/Vagrantfile +++ /dev/null @@ -1,6 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : -Vagrant.configure("2") do |config| - config.vm.box = "ubuntu/bionic64" - config.vm.provision "shell", path: "provision.sh" -end diff --git a/archived_packages/wings/analysis_options.yaml b/archived_packages/wings/analysis_options.yaml deleted file mode 100644 index ea2c9e94..00000000 --- a/archived_packages/wings/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml \ No newline at end of file diff --git a/archived_packages/wings/benchmark/empty.dart b/archived_packages/wings/benchmark/empty.dart deleted file mode 100644 index 07e41bf9..00000000 --- a/archived_packages/wings/benchmark/empty.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'package:angel_framework/angel_framework.dart'; -import 'util.dart'; - -const AngelBenchmark emptyBenchmark = _EmptyBenchmark(); - -void main() => runBenchmarks([emptyBenchmark]); - -class _EmptyBenchmark implements AngelBenchmark { - const _EmptyBenchmark(); - - @override - String get name => 'empty'; - - @override - FutureOr rawHandler(HttpRequest req, HttpResponse res) { - return res.close(); - } - - @override - void setupAngel(Angel app) {} -} diff --git a/archived_packages/wings/benchmark/util.dart b/archived_packages/wings/benchmark/util.dart deleted file mode 100644 index e51f8bcd..00000000 --- a/archived_packages/wings/benchmark/util.dart +++ /dev/null @@ -1,112 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -import 'package:angel_wings/angel_wings.dart'; -import 'package:io/ansi.dart'; -import 'package:tuple/tuple.dart'; - -Future _runWrk( - {ProcessStartMode mode = ProcessStartMode.inheritStdio}) async { - return await Process.start('wrk', ['http://localhost:$testPort'], mode: mode); -} - -Future _warmUp() async { - var wrk = await _runWrk(); - await wrk.exitCode; - // await wrk.stderr.drain(); - // await wrk.stdout.drain(); -} - -Future _10s() => Future.delayed(Duration(seconds: 10)); - -const testPort = 8877; - -Future runBenchmarks(Iterable benchmarks, - {Iterable factories = const [ - // 'angel_http', - 'angel_wings', - ]}) async { - for (var benchmark in benchmarks) { - print(magenta.wrap('Entering benchmark: ${benchmark.name}')); - - // // Run dart:io - // print(lightGray.wrap('Booting dart:io server (waiting 10s)...')); - // var isolates = []; - // for (int i = 0; i < Platform.numberOfProcessors; i++) { - // isolates.add(await Isolate.spawn(_httpIsolate, benchmark)); - // } - - // await _10s(); - // print(lightGray.wrap('Warming up dart:io server...')); - // await _warmUp(); - - // stdout - // ..write(lightGray.wrap('Now running `wrk` for ')) - // ..write(cyan.wrap(benchmark.name)) - // ..writeln(lightGray.wrap(' (waiting 10s)...')); - // var wrk = await _runWrk(mode: ProcessStartMode.inheritStdio); - // await wrk.exitCode; - // isolates.forEach((i) => i.kill(priority: Isolate.immediate)); - - // Run Angel HTTP, Wings - for (var fac in factories) { - print(lightGray.wrap('Booting $fac server...')); - - var isolates = []; - for (var i = 0; i < Platform.numberOfProcessors; i++) { - isolates - .add(await Isolate.spawn(_angelIsolate, Tuple2(benchmark, fac))); - } - - await _10s(); - print(lightGray.wrap('Warming up $fac server...')); - await _warmUp(); - stdout - ..write(lightGray.wrap('Now running `wrk` for ')) - ..write(cyan.wrap(benchmark.name)) - ..writeln(lightGray.wrap('...')); - var wrk = await _runWrk(mode: ProcessStartMode.inheritStdio); - await wrk.exitCode; - } - } - - exit(0); -} - -/* -void _httpIsolate(AngelBenchmark benchmark) { - Future(() async { - var raw = await HttpServer.bind(InternetAddress.loopbackIPv4, testPort, - shared: true); - raw.listen((r) => benchmark.rawHandler(r, r.response)); - }); -} -*/ - -void _angelIsolate(Tuple2 args) { - Future(() async { - var app = Angel(); - late Driver driver; - - if (args.item2 == 'angel_http') { - driver = AngelHttp.custom(app, startShared); - } else if (args.item2 == 'angel_wings') { - driver = AngelWings.custom(app, startSharedWings); - } - - await app.configure(args.item1.setupAngel); - await driver.startServer(InternetAddress.loopbackIPv4, testPort); - }); -} - -abstract class AngelBenchmark { - const AngelBenchmark(); - - String get name; - - FutureOr setupAngel(Angel app); - - FutureOr rawHandler(HttpRequest req, HttpResponse res); -} diff --git a/archived_packages/wings/example/main.dart b/archived_packages/wings/example/main.dart deleted file mode 100644 index c33b9b06..00000000 --- a/archived_packages/wings/example/main.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'dart:io'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_static/angel_static.dart'; -import 'package:angel_wings/angel_wings.dart'; -import 'package:file/local.dart'; -import 'package:logging/logging.dart'; -import 'package:pretty_logging/pretty_logging.dart'; - -void main() async { - hierarchicalLoggingEnabled = true; - - var logger = Logger.detached('wings') - ..level = Level.ALL - ..onRecord.listen(prettyLog); - var app = Angel(logger: logger); - var wings = AngelWings(app); - var fs = LocalFileSystem(); - var vDir = CachingVirtualDirectory(app, fs, - source: fs.currentDirectory, allowDirectoryListing: true); - - app.mimeTypeResolver.addExtension('yaml', 'text/x-yaml'); - - app.get('/', (req, res) => 'WINGS!!!'); - app.post('/', (req, res) async { - await req.parseBody(); - return req.bodyAsMap; - }); - - app.fallback(vDir.handleRequest); - app.fallback((req, res) => throw AngelHttpException.notFound()); - - await wings.startServer(InternetAddress.loopbackIPv4, 3000); - print('Listening at ${wings.uri}'); -} diff --git a/archived_packages/wings/example/shared.dart b/archived_packages/wings/example/shared.dart deleted file mode 100644 index ab3752c2..00000000 --- a/archived_packages/wings/example/shared.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_wings/angel_wings.dart'; - -void main() async { - var app = Angel(); - var wings1 = AngelWings.custom(app, startSharedWings); - var wings2 = AngelWings.custom(app, startSharedWings); - var wings3 = AngelWings.custom(app, startSharedWings); - var wings4 = AngelWings.custom(app, startSharedWings); - await wings1.startServer('127.0.0.1', 3000); - await wings2.startServer('127.0.0.1', 3000); - await wings3.startServer('127.0.0.1', 3000); - await wings4.startServer('127.0.0.1', 3000); - print(wings1.uri); - print(wings2.uri); - print(wings3.uri); - print(wings4.uri); - await wings1.close(); - await wings2.close(); - await wings3.close(); - await wings4.close(); -} diff --git a/archived_packages/wings/example/socket.dart b/archived_packages/wings/example/socket.dart deleted file mode 100644 index 3a10a1c7..00000000 --- a/archived_packages/wings/example/socket.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'dart:convert'; -import 'dart:typed_data'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_wings/angel_wings.dart'; - -void main() async { - var app = Angel(); - var socket = await WingsSocket.bind('127.0.0.1', 3000); - print('Listening at http://localhost:3000'); - - await for (var fd in socket) { - var response = ''' -HTTP/1.1 200 Not Found\r -Date: Fri, 31 Dec 1999 23:59:59 GMT\r -server: wings-test\r\n\r -Nope, nothing's here! -\r\n\r -'''; - var bytes = utf8.encode(response); - var data = Uint8List.fromList(bytes); - var rq = await WingsRequestContext.from(app, fd); - print('Yay: $rq'); - print(rq.headers); - writeToNativeSocket(fd.fileDescriptor, data); - closeNativeSocketDescriptor(fd.fileDescriptor); - } -} diff --git a/archived_packages/wings/lib/angel_wings.dart b/archived_packages/wings/lib/angel_wings.dart deleted file mode 100644 index c1cda8f7..00000000 --- a/archived_packages/wings/lib/angel_wings.dart +++ /dev/null @@ -1,4 +0,0 @@ -export 'src/wings_driver.dart'; -export 'src/wings_request.dart'; -export 'src/wings_response.dart'; -export 'src/wings_socket.dart'; diff --git a/archived_packages/wings/lib/src/CMakeLists.txt b/archived_packages/wings/lib/src/CMakeLists.txt deleted file mode 100644 index 758fce7d..00000000 --- a/archived_packages/wings/lib/src/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include_directories("${CMAKE_CURRENT_LIST_DIR}") -add_dart_native_extension(angel_wings - http-parser/http_parser.c - angel_wings.h angel_wings.cc - bind.cc http.cc wings_socket.cc - util.cc) -install(TARGETS angel_wings LIBRARY DESTINATION "${CMAKE_CURRENT_LIST_DIR}") -install(TARGETS angel_wings LIBRARY DESTINATION "${CMAKE_CURRENT_LIST_DIR}/../..") diff --git a/archived_packages/wings/lib/src/angel_wings.cc b/archived_packages/wings/lib/src/angel_wings.cc deleted file mode 100644 index 74d3a8ef..00000000 --- a/archived_packages/wings/lib/src/angel_wings.cc +++ /dev/null @@ -1,55 +0,0 @@ -#include "angel_wings.h" -#include -#include -#include -#include - -// The name of the initialization function is the extension name followed -// by _Init. -DART_EXPORT Dart_Handle angel_wings_Init(Dart_Handle parent_library) { - if (Dart_IsError(parent_library)) - return parent_library; - - Dart_Handle result_code = - Dart_SetNativeResolver(parent_library, ResolveName, NULL); - if (Dart_IsError(result_code)) - return result_code; - - return Dart_Null(); -} - -Dart_Handle HandleError(Dart_Handle handle) { - if (Dart_IsError(handle)) - Dart_PropagateError(handle); - return handle; -} - -Dart_NativeFunction ResolveName(Dart_Handle name, int argc, - bool *auto_setup_scope) { - // If we fail, we return NULL, and Dart throws an exception. - if (!Dart_IsString(name)) - return NULL; - Dart_NativeFunction result = NULL; - const char *cname; - HandleError(Dart_StringToCString(name, &cname)); - - if (strcmp("Dart_WingsSocket_bindIPv4", cname) == 0) - result = Dart_WingsSocket_bindIPv4; - if (strcmp("Dart_WingsSocket_bindIPv6", cname) == 0) - result = Dart_WingsSocket_bindIPv6; - if (strcmp("Dart_WingsSocket_getAddress", cname) == 0) - result = Dart_WingsSocket_getAddress; - if (strcmp("Dart_WingsSocket_getPort", cname) == 0) - result = Dart_WingsSocket_getPort; - if (strcmp("Dart_WingsSocket_write", cname) == 0) - result = Dart_WingsSocket_write; - if (strcmp("Dart_WingsSocket_closeDescriptor", cname) == 0) - result = Dart_WingsSocket_closeDescriptor; - if (strcmp("Dart_WingsSocket_close", cname) == 0) - result = Dart_WingsSocket_close; - if (strcmp("Dart_WingsSocket_listen", cname) == 0) - result = Dart_WingsSocket_listen; - if (strcmp("Dart_WingsSocket_parseHttp", cname) == 0) - result = Dart_WingsSocket_parseHttp; - return result; -} \ No newline at end of file diff --git a/archived_packages/wings/lib/src/angel_wings.h b/archived_packages/wings/lib/src/angel_wings.h deleted file mode 100644 index 3aeda0b7..00000000 --- a/archived_packages/wings/lib/src/angel_wings.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ANGEL_WINGS_WINGS_H -#define ANGEL_WINGS_WINGS_H - -#include "angel_wings.h" -#include -#include - -Dart_NativeFunction ResolveName(Dart_Handle name, int argc, - bool *auto_setup_scope); -Dart_Handle HandleError(Dart_Handle handle); - -void wingsThrowError(const char *msg, const char *lib = "dart:core", - const char *name = "StateError", int n = -1); -void Dart_WingsSocket_bindIPv4(Dart_NativeArguments arguments); -void Dart_WingsSocket_bindIPv6(Dart_NativeArguments arguments); -void Dart_WingsSocket_getAddress(Dart_NativeArguments arguments); -void Dart_WingsSocket_getPort(Dart_NativeArguments arguments); -void Dart_WingsSocket_write(Dart_NativeArguments arguments); -void Dart_WingsSocket_closeDescriptor(Dart_NativeArguments arguments); -void Dart_WingsSocket_close(Dart_NativeArguments arguments); -void Dart_WingsSocket_listen(Dart_NativeArguments arguments); -void Dart_WingsSocket_parseHttp(Dart_NativeArguments arguments); -void wingsHttpCallback(Dart_Port dest_port_id, Dart_CObject *message); - -#endif \ No newline at end of file diff --git a/archived_packages/wings/lib/src/bind.cc b/archived_packages/wings/lib/src/bind.cc deleted file mode 100644 index 26d90781..00000000 --- a/archived_packages/wings/lib/src/bind.cc +++ /dev/null @@ -1,161 +0,0 @@ -#include "angel_wings.h" -#include "wings_socket.h" -#include -#include -using namespace wings; - -void getWingsSocketInfo(Dart_NativeArguments arguments, WingsSocketInfo *info); - -WingsSocket *wingsFindSocket(Dart_NativeArguments arguments, - const WingsSocketInfo &info, int af); - -WingsSocket *wingsBindNewSocket(Dart_NativeArguments arguments, - const WingsSocketInfo &info, int af); - -void wingsReturnBound(Dart_NativeArguments arguments, WingsSocket *socket); - -void Dart_WingsSocket_bind(sa_family_t af, Dart_NativeArguments arguments) { - WingsSocketInfo info; - getWingsSocketInfo(arguments, &info); - WingsSocket *socket = wingsFindSocket(arguments, info, af); - wingsReturnBound(arguments, socket); -} - -void Dart_WingsSocket_bindIPv4(Dart_NativeArguments arguments) { - Dart_WingsSocket_bind(AF_INET, arguments); -} - -void Dart_WingsSocket_bindIPv6(Dart_NativeArguments arguments) { - Dart_WingsSocket_bind(AF_INET6, arguments); -} - -void wingsReturnBound(Dart_NativeArguments arguments, WingsSocket *socket) { - Dart_Port sendPort; - HandleError( - Dart_SendPortGetId(Dart_GetNativeArgument(arguments, 5), &sendPort)); - socket->incrRef(sendPort); - auto ptr = (uint64_t)socket; - Dart_Handle ptrHandle = Dart_NewIntegerFromUint64(ptr); - Dart_SetReturnValue(arguments, ptrHandle); -} - -WingsSocket *wingsFindSocket(Dart_NativeArguments arguments, - const WingsSocketInfo &info, int af) { - // Find an existing server, if any. - if (info.shared) { - // std::cout << info.address << std::endl; - // std::cout << globalSocketList.size() << std::endl; - for (auto *socket : globalSocketList) { - if (info.equals(socket->getInfo())) { - return socket; - } - } - } - - return wingsBindNewSocket(arguments, info, af); -} - -WingsSocket *wingsBindNewSocket(Dart_NativeArguments arguments, - const WingsSocketInfo &info, int af) { - sockaddr *addr; - sockaddr_in v4; - sockaddr_in6 v6; - int ret; - - int sock = socket(af, SOCK_STREAM, IPPROTO_TCP); - - if (sock < 0) { - wingsThrowError("Failed to create socket."); - return nullptr; - } - - int i = 1; - ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)); - - if (ret < 0) { - wingsThrowError("Cannot reuse address for socket."); - return nullptr; - } - - // TODO: Only on Mac??? - // ret = setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &i, sizeof(i)); - - // if (ret < 0) - // { - // wingsThrowStateError("Cannot reuse port for socket."); - // return; - // } - - if (af == AF_INET6) { - v6.sin6_family = AF_INET6; - v6.sin6_port = htons((uint16_t)info.port); - ret = inet_pton(AF_INET6, info.address, &v6.sin6_addr.s6_addr); - if (ret >= 0) - ret = bind(sock, (const sockaddr *)&v6, sizeof(v6)); - } else { - v4.sin_family = AF_INET; - v4.sin_port = htons((uint16_t)info.port); - v4.sin_addr.s_addr = inet_addr(info.address); - bind(sock, (const sockaddr *)&v4, sizeof(v4)); - } - - if (ret < 0) { - wingsThrowError("Failed to bind socket."); - return nullptr; - } - - if (listen(sock, SOMAXCONN) < 0) { - wingsThrowError("Failed to set SOMAXCONN on bound socket."); - return nullptr; - } - - if (listen(sock, (int)info.backlog) < 0) { - wingsThrowError("Failed to set backlog on bound socket."); - return nullptr; - } - - if (fcntl(sock, F_SETFL, O_NONBLOCK) == -1) { - wingsThrowError("Failed to make socket non-blocking."); - return nullptr; - } - - auto *out = new WingsSocket(af, sock, info); - globalSocketList.push_back(out); - return out; -} - -void getWingsSocketInfo(Dart_NativeArguments arguments, WingsSocketInfo *info) { - Dart_Handle addressHandle = Dart_GetNativeArgument(arguments, 0); - Dart_Handle portHandle = Dart_GetNativeArgument(arguments, 1); - Dart_Handle sharedHandle = Dart_GetNativeArgument(arguments, 2); - Dart_Handle backlogHandle = Dart_GetNativeArgument(arguments, 3); - Dart_Handle v6OnlyHandle = Dart_GetNativeArgument(arguments, 4); - info->sendPortHandle = Dart_GetNativeArgument(arguments, 5); - - HandleError(Dart_StringToCString(addressHandle, &info->address)); - HandleError(Dart_IntegerToUint64(portHandle, &info->port)); - HandleError(Dart_BooleanValue(sharedHandle, &info->shared)); - HandleError(Dart_IntegerToUint64(backlogHandle, &info->backlog)); - HandleError(Dart_BooleanValue(v6OnlyHandle, &info->v6Only)); -} - -void wingsThrowError(const char *msg, const char *lib, const char *name, - int n) { - Dart_Handle msgHandle = Dart_NewStringFromCString(msg); - Dart_Handle emptyHandle = Dart_NewStringFromCString(""); - Dart_Handle stateErrorHandle = Dart_NewStringFromCString(name); - Dart_Handle dartCoreHandle = Dart_NewStringFromCString(lib); - Dart_Handle dartCore = Dart_LookupLibrary(dartCoreHandle); - Dart_Handle stateError = Dart_GetType(dartCore, stateErrorHandle, 0, nullptr); - - std::vector args; - args.push_back(msgHandle); - - if (n > -1) { - args.push_back(Dart_NewInteger(n)); - } - - Dart_Handle errHandle = - Dart_New(stateError, emptyHandle, args.size(), args.data()); - Dart_ThrowException(errHandle); -} \ No newline at end of file diff --git a/archived_packages/wings/lib/src/http.cc b/archived_packages/wings/lib/src/http.cc deleted file mode 100644 index a9fe7183..00000000 --- a/archived_packages/wings/lib/src/http.cc +++ /dev/null @@ -1,175 +0,0 @@ -#include - -#include "angel_wings.h" -#include "wings_socket.h" -#include -#include -using namespace wings; - -void Dart_WingsSocket_parseHttp(Dart_NativeArguments arguments) { - Dart_Port service_port = - Dart_NewNativePort("WingsHttpCallback", &wingsHttpCallback, true); - Dart_Handle send_port = Dart_NewSendPort(service_port); - Dart_SetReturnValue(arguments, send_port); -} - -struct wingsHttp { - Dart_Port port; - std::string lastHeader; -}; - -void wingsHttpCallback(Dart_Port dest_port_id, Dart_CObject *message) { - int64_t fd = -1; - Dart_Port outPort = message->value.as_array.values[0]->value.as_send_port.id; - Dart_CObject *fdArg = message->value.as_array.values[1]; - - wingsHttp httpData = {outPort}; - -#define theStruct (*((wingsHttp *)parser->data)) -#define thePort theStruct.port -#define sendInt(n) \ - { \ - Dart_CObject obj; \ - obj.type = Dart_CObject_kInt64; \ - obj.value.as_int64 = (n); \ - Dart_PostCObject(thePort, &obj); \ - } -#define sendString(n) \ - if (length > 0) { \ - Dart_CObject typeObj; \ - typeObj.type = Dart_CObject_kInt32; \ - typeObj.value.as_int32 = (n); \ - std::string str(at, length); \ - Dart_CObject strObj; \ - strObj.type = Dart_CObject_kString; \ - strObj.value.as_string = (char *)str.c_str(); \ - Dart_CObject *values[2] = {&typeObj, &strObj}; \ - Dart_CObject out; \ - out.type = Dart_CObject_kArray; \ - out.value.as_array.length = 2; \ - out.value.as_array.values = values; \ - Dart_PostCObject(thePort, &out); \ - } - - if (fdArg->type == Dart_CObject_kInt32) { - fd = (int64_t)fdArg->value.as_int32; - } else { - fd = fdArg->value.as_int64; - } - - if (fd != -1) { - http_parser_settings settings; - - settings.on_message_begin = [](http_parser *parser) { return 0; }; - - settings.on_headers_complete = [](http_parser *parser) { - Dart_CObject type; - type.type = Dart_CObject_kInt32; - type.value.as_int32 = 2; - Dart_CObject value; - value.type = Dart_CObject_kInt32; - value.value.as_int32 = parser->method; - Dart_CObject *values[2] = {&type, &value}; - Dart_CObject out; - out.type = Dart_CObject_kArray; - out.value.as_array.length = 2; - out.value.as_array.values = values; - Dart_PostCObject(thePort, &out); - sendInt(100); - return 0; - }; - - settings.on_message_complete = [](http_parser *parser) { - sendInt(200); - return 0; - }; - - settings.on_chunk_complete = [](http_parser *parser) { return 0; }; - - settings.on_chunk_header = [](http_parser *parser) { return 0; }; - - settings.on_url = [](http_parser *parser, const char *at, size_t length) { - sendString(0); - return 0; - }; - - settings.on_header_field = [](http_parser *parser, const char *at, - size_t length) { - theStruct.lastHeader = std::string(at, length); - return 0; - }; - - settings.on_header_value = [](http_parser *parser, const char *at, - size_t length) { - if (!theStruct.lastHeader.empty()) { - std::string vStr(at, length); - Dart_CObject type; - type.type = Dart_CObject_kInt32; - type.value.as_int32 = 1; - Dart_CObject name; - name.type = Dart_CObject_kString; - name.value.as_string = (char *)theStruct.lastHeader.c_str(); - Dart_CObject value; - value.type = Dart_CObject_kString; - value.value.as_string = (char *)vStr.c_str(); - Dart_CObject *values[3] = {&type, &name, &value}; - Dart_CObject out; - out.type = Dart_CObject_kArray; - out.value.as_array.length = 3; - out.value.as_array.values = values; - Dart_PostCObject(thePort, &out); - theStruct.lastHeader.clear(); - } - return 0; - }; - - settings.on_body = [](http_parser *parser, const char *at, size_t length) { - Dart_CObject obj; - obj.type = Dart_CObject_kTypedData; - obj.value.as_typed_data.type = Dart_TypedData_kUint8; - obj.value.as_typed_data.length = length; - obj.value.as_typed_data.values = (uint8_t *)at; - Dart_PostCObject(thePort, &obj); - return 0; - }; - - size_t len = 80 * 1024, nparsed = 0; - char buf[len]; - ssize_t recved = 0; - memset(buf, 0, sizeof(buf)); - // http_parser parser; - auto *parser = (http_parser *)malloc(sizeof(http_parser)); - http_parser_init(parser, HTTP_BOTH); - parser->data = &httpData; - - while ((recved = recv(fd, buf, len, 0)) >= 0) { - if (false) // (isUpgrade) - { - // send_string(&parser, buf, (size_t)recved, 7, true); - } else { - /* Start up / continue the parser. - * Note we pass recved==0 to signal that EOF has been received. - */ - nparsed = http_parser_execute(parser, &settings, buf, recved); - - if (nparsed != recved) { - // TODO: End it...! - } else if (recved == 0) { - break; - } - - // if ((isUpgrade = parser.upgrade) == 1) - // { - // send_notification(&parser, 6); - // } - // else if (nparsed != recved) - // { - // close(rq->sock); - // return; - // } - } - - // memset(buf, 0, len); - } - } -} \ No newline at end of file diff --git a/archived_packages/wings/lib/src/libangel_wings.dylib b/archived_packages/wings/lib/src/libangel_wings.dylib deleted file mode 100644 index fbcfc381..00000000 Binary files a/archived_packages/wings/lib/src/libangel_wings.dylib and /dev/null differ diff --git a/archived_packages/wings/lib/src/libangel_wings.so b/archived_packages/wings/lib/src/libangel_wings.so deleted file mode 100644 index 92b8f107..00000000 Binary files a/archived_packages/wings/lib/src/libangel_wings.so and /dev/null differ diff --git a/archived_packages/wings/lib/src/util.cc b/archived_packages/wings/lib/src/util.cc deleted file mode 100644 index 227f4e24..00000000 --- a/archived_packages/wings/lib/src/util.cc +++ /dev/null @@ -1,146 +0,0 @@ -#include - -#include "angel_wings.h" -#include "wings_socket.h" -#include -#include -using namespace wings; - -void Dart_WingsSocket_listen(Dart_NativeArguments arguments) { - uint64_t ptr; - Dart_Handle pointerHandle = Dart_GetNativeArgument(arguments, 0); - HandleError(Dart_IntegerToUint64(pointerHandle, &ptr)); - - auto *socket = (WingsSocket *)ptr; - socket->start(arguments); -} - -struct wingsSockName { - sa_family_t family; - sockaddr_in v4; - sockaddr_in6 v6; - - struct sockaddr *ptr() const { - if (family == AF_INET6) { - return (sockaddr *)&v6; - } else { - return (sockaddr *)&v4; - } - } - - void *addrPtr() const { - if (family == AF_INET6) { - return (void *)&v6.sin6_addr; - } else { - return (void *)&v4.sin_addr; - } - } - - socklen_t length() const { - if (family == AF_INET6) { - return sizeof(v6); - } else { - return sizeof(v4); - } - } -}; - -void wingsThrowOSError() { - wingsThrowError(strerror(errno), "dart:io", "OSError", errno); -} - -bool wingsReadSocket(Dart_NativeArguments arguments, wingsSockName *out) { - uint64_t ptr; - Dart_Handle pointerHandle = Dart_GetNativeArgument(arguments, 0); - HandleError(Dart_IntegerToUint64(pointerHandle, &ptr)); - - auto *socket = (WingsSocket *)ptr; - int fd = socket->getFD(); - - socklen_t len; - out->family = socket->getFamily(); - len = out->length(); - - int result; - - // result = connect(fd, out->ptr(), len); - - // if (result < 0) - // { - // wingsThrowOSError(); - // return false; - // } - - result = getsockname(fd, out->ptr(), &len); - - if (result == -1) { - wingsThrowOSError(); - return false; - } - - return true; -} - -void Dart_WingsSocket_getAddress(Dart_NativeArguments arguments) { - wingsSockName sock; - if (wingsReadSocket(arguments, &sock)) { - char addrBuf[INET6_ADDRSTRLEN + 1] = {0}; - - auto *result = - inet_ntop(sock.family, sock.addrPtr(), addrBuf, sock.length()); - - if (result == NULL) { - wingsThrowOSError(); - } - - Dart_Handle outHandle = Dart_NewStringFromCString(addrBuf); - Dart_SetReturnValue(arguments, outHandle); - } -} - -void Dart_WingsSocket_getPort(Dart_NativeArguments arguments) { - wingsSockName sock; - if (wingsReadSocket(arguments, &sock)) { - Dart_Handle outHandle; - - if (sock.family == AF_INET6) { - outHandle = Dart_NewIntegerFromUint64(ntohs(sock.v6.sin6_port)); - } else { - outHandle = Dart_NewIntegerFromUint64(ntohs(sock.v4.sin_port)); - } - - Dart_SetReturnValue(arguments, outHandle); - } -} - -void Dart_WingsSocket_write(Dart_NativeArguments arguments) { - int64_t fd; - void *data; - Dart_TypedData_Type type; - intptr_t len; - Dart_Handle fdHandle = Dart_GetNativeArgument(arguments, 0); - Dart_Handle dataHandle = Dart_GetNativeArgument(arguments, 1); - HandleError(Dart_IntegerToInt64(fdHandle, &fd)); - HandleError(Dart_TypedDataAcquireData(dataHandle, &type, &data, &len)); - write(fd, data, len); - HandleError(Dart_TypedDataReleaseData(dataHandle)); -} - -void Dart_WingsSocket_closeDescriptor(Dart_NativeArguments arguments) { - int64_t fd; - Dart_Handle fdHandle = Dart_GetNativeArgument(arguments, 0); - HandleError(Dart_IntegerToInt64(fdHandle, &fd)); - close(fd); -} - -void Dart_WingsSocket_close(Dart_NativeArguments arguments) { - Dart_Port port; - uint64_t ptr; - Dart_Handle pointerHandle = Dart_GetNativeArgument(arguments, 0); - Dart_Handle sendPortHandle = Dart_GetNativeArgument(arguments, 1); - HandleError(Dart_IntegerToUint64(pointerHandle, &ptr)); - HandleError(Dart_SendPortGetId(sendPortHandle, &port)); - - auto *socket = (WingsSocket *)ptr; - socket->decrRef(port); -} \ No newline at end of file diff --git a/archived_packages/wings/lib/src/wings_driver.dart b/archived_packages/wings/lib/src/wings_driver.dart deleted file mode 100644 index 003bbcb5..00000000 --- a/archived_packages/wings/lib/src/wings_driver.dart +++ /dev/null @@ -1,98 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:io' show Cookie; -import 'dart:typed_data'; -import 'package:angel_framework/angel_framework.dart'; -import 'wings_request.dart'; -import 'wings_response.dart'; -import 'wings_socket.dart'; - -Future startSharedWings(dynamic addr, int port) { - return WingsSocket.bind(addr, port, shared: true); -} - -class AngelWings extends Driver { - factory AngelWings(Angel app) { - return AngelWings.custom(app, WingsSocket.bind); - } - - AngelWings.custom( - Angel app, Future Function(dynamic, int) serverGenerator) - : super(app, serverGenerator); - - @override - void addCookies(int? response, Iterable cookies) { - for (var cookie in cookies) { - setHeader(response, 'set-cookie', cookie.toString()); - } - } - - @override - Future close() async { - await server?.close(); - return super.close(); - } - - @override - Future closeResponse(int? response) { - closeNativeSocketDescriptor(response); - return Future.value(); - } - - @override - Future createRequestContext( - WingsClientSocket request, int? response) { - return WingsRequestContext.from(app, request); - } - - @override - Future createResponseContext( - WingsClientSocket request, int? response, - [WingsRequestContext? correspondingRequest]) { - return Future.value(WingsResponseContext( - app, request.fileDescriptor, correspondingRequest)); - } - - @override - Stream createResponseStreamFromRawRequest(WingsClientSocket request) { - return Stream.fromIterable([request.fileDescriptor]); - } - - @override - void setChunkedEncoding(int? response, bool value) { - // TODO: implement setChunkedEncoding - } - - @override - void setContentLength(int? response, int length) { - writeStringToResponse(response, 'content-length: $length\r\n'); - } - - @override - void setHeader(int? response, String key, String value) { - writeStringToResponse(response, '$key: $value\r\n'); - } - - @override - void setStatusCode(int? response, int value) { - // HTTP-Version SP Status-Code SP Reason-Phrase CRLF - writeStringToResponse(response, 'HTTP/1.1 $value\r\n'); - } - - @override - Uri get uri { - return Uri(scheme: 'http', host: server!.address.address, port: server!.port); - } - - @override - void writeStringToResponse(int? response, String value) { - writeToResponse(response, utf8.encode(value)); - } - - @override - void writeToResponse(int? response, List data) { - var buf = data is Uint8List ? data : Uint8List.fromList(data); - writeToNativeSocket(response, buf); - } -} diff --git a/archived_packages/wings/lib/src/wings_request.dart b/archived_packages/wings/lib/src/wings_request.dart deleted file mode 100644 index 90781169..00000000 --- a/archived_packages/wings/lib/src/wings_request.dart +++ /dev/null @@ -1,218 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; -import 'dart:typed_data'; -import 'package:angel_container/angel_container.dart'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:mock_request/mock_request.dart'; -import 'wings_socket.dart'; - -//enum _ParseState { method, url, headerField, headerValue, body } - -final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)'); - -class WingsRequestContext extends RequestContext { - @override - final WingsClientSocket rawRequest; - @override - final Container container; - - final StreamController> _body = StreamController(); - List? _cookies, __cookies; - final LockableMockHttpHeaders _headers = LockableMockHttpHeaders(); - final RawReceivePort _recv; - late InternetAddress _remoteAddress; - String? _method, _override, _path; - Uri? _uri; - - @override - Angel? app; - - WingsRequestContext._(Angel this.app, this.rawRequest, this._recv) - : container = app.container!.createChild(); - - @override - Future close() async { - await _body.close(); - _recv.close(); - await super.close(); - } - - static const int DELETE = 0, - GET = 1, - HEAD = 2, - POST = 3, - PUT = 4, - CONNECT = 5, - OPTIONS = 6, - TRACE = 7, - COPY = 8, - LOCK = 9, - MKCOL = 10, - MOVE = 11, - PROPFIND = 12, - PROPPATCH = 13, - SEARCH = 14, - UNLOCK = 15, - BIND = 16, - REBIND = 17, - UNBIND = 18, - ACL = 19, - REPORT = 20, - MKACTIVITY = 21, - CHECKOUT = 22, - MERGE = 23, - MSEARCH = 24, - NOTIFY = 25, - SUBSCRIBE = 26, - UNSUBSCRIBE = 27, - PATCH = 28, - PURGE = 29, - MKCALENDAR = 30, - LINK = 31, - UNLINK = 32, - SOURCE = 33; - - static String methodToString(int method) { - switch (method) { - case DELETE: - return 'DELETE'; - case GET: - return 'GET'; - case HEAD: - return 'HEAD'; - case POST: - return 'POST'; - case PUT: - return 'PUT'; - case CONNECT: - return 'CONNECT'; - case OPTIONS: - return 'OPTIONS'; - case PATCH: - return 'PATCH'; - case PURGE: - return 'PURGE'; - default: - throw ArgumentError('Unknown method $method.'); - } - } - - static Future from(Angel app, WingsClientSocket socket) { - // var state = _ParseState.url; - var c = Completer(); - var recv = RawReceivePort(); - var rq = WingsRequestContext._(app, socket, recv); - rq._remoteAddress = socket.remoteAddress; - var ct = StreamController(); - recv.handler = ct.add; - recv.handler = (ee) { - if (ee is Uint8List) { - if (!rq._body.isClosed) rq._body.add(ee); - } else if (ee is List) { - var type = ee[0] as int; - - if (type == 2) { - rq._method = methodToString(ee[1] as int); - } else { - var value = ee[1] as String; - - if (type == 0) { - rq._uri = Uri.parse(value); - var path = rq._uri!.path.replaceAll(_straySlashes, ''); - if (path.isEmpty) path = '/'; - rq._path = path; - } else if (type == 1) { - var k = value, v = ee[2] as String; - if (k == 'cookie') { - rq.__cookies!.add(Cookie.fromSetCookieValue(v)); - } else { - rq._headers.add(k, v); - } - } else { - // print("h: $ee');"); - } - } - } else if (ee == 100) { - // Headers done, just listen for body. - c.complete(rq); - } else if (ee == 200) { - // Message complete. - rq._body.close(); - } - // if (state == _ParseState.url) { - // rq._uri = Uri.parse(e as String); - // var path = rq._uri.path.replaceAll(_straySlashes, ''); - // if (path.isEmpty) path = '/'; - // rq._path = path; - // state = _ParseState.headerField; - // } else if (state == _ParseState.headerField) { - // if (e == 0) { - // state = _ParseState.method; - // } else { - // lastHeader = e as String; //Uri.decodeFull(e as String); - // state = _ParseState.headerValue; - // } - // } else if (state == _ParseState.headerValue) { - // if (e == 0) { - // state = _ParseState.method; - // } else { - // var value = e as String; //Uri.decodeFull(e as String); - // if (lastHeader != null) { - // if (lastHeader == 'cookie') { - // rq.__cookies.add(Cookie.fromSetCookieValue(value)); - // } else { - // rq._headers.add(lastHeader, value); - // } - // lastHeader = null; - // } - // } - // state = _ParseState.headerField; - // } else if (state == _ParseState.method) { - // rq._method = methodToString(e as int); - // state = _ParseState.body; - // c.complete(rq); - // } else if (state == _ParseState.body) { - // if (e == 1) { - // rq._body.close(); - // } else { - // rq._body.add(e as List); - // } - // } - }; - wingsParseHttp().send([recv.sendPort, socket.fileDescriptor]); - return c.future; - } - - @override - Stream> get body => _body.stream; - - @override - List get cookies => _cookies ??= List.unmodifiable(__cookies!); - - @override - HttpHeaders get headers => _headers; - - @override - String get hostname => headers.value('host')!; - - @override - String get method => (_override ??= - (headers.value('x-http-method-override')?.toUpperCase() ?? _method))!; - - @override - String get originalMethod => _method!; - - @override - String get path => _path!; - - @override - InternetAddress get remoteAddress => _remoteAddress; - - @override - // TODO: implement session - HttpSession? get session => null; - - @override - Uri? get uri => _uri; -} diff --git a/archived_packages/wings/lib/src/wings_response.dart b/archived_packages/wings/lib/src/wings_response.dart deleted file mode 100644 index 2747a829..00000000 --- a/archived_packages/wings/lib/src/wings_response.dart +++ /dev/null @@ -1,213 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:charcode/ascii.dart'; -import 'wings_request.dart'; -import 'wings_socket.dart'; - -class WingsResponseContext extends ResponseContext { - @override - final Angel app; - - @override - final WingsRequestContext? correspondingRequest; - - LockableBytesBuilder? _buffer; - - @override - final int? rawResponse; - - bool _isDetached = false, _isClosed = false, _streamInitialized = false; - - WingsResponseContext(this.app, this.rawResponse, [this.correspondingRequest]); - - Iterable? __allowedEncodings; - - Iterable? get _allowedEncodings { - return __allowedEncodings ??= correspondingRequest!.headers - .value('accept-encoding') - ?.split(',') - .map((s) => s.trim()) - .where((s) => s.isNotEmpty) - .map((str) { - // Ignore quality specifications in accept-encoding - // ex. gzip;q=0.8 - if (!str.contains(';')) return str; - return str.split(';')[0]; - }); - } - - bool _openStream() { - if (!_streamInitialized) { - // If this is the first stream added to this response, - // then add headers, status code, etc. - var outHeaders = {}; - var statusLine = - utf8.encode('HTTP/1.1 $statusCode').followedBy([$cr, $lf]); - writeToNativeSocket(rawResponse, Uint8List.fromList(statusLine.toList())); - - headers.forEach((k, v) => outHeaders[k] = v); - - if (headers.containsKey('content-length')) { - var l = int.tryParse(headers['content-length']!); - if (l != null) { - outHeaders['content-length'] = l.toString(); - } - } - - outHeaders['content-type'] = contentType.toString(); - - if (encoders.isNotEmpty && correspondingRequest != null) { - if (_allowedEncodings != null) { - for (var encodingName in _allowedEncodings!) { - Converter, List>? encoder; - var key = encodingName; - - if (encoders.containsKey(encodingName)) { - encoder = encoders[encodingName]; - } else if (encodingName == '*') { - encoder = encoders[key = encoders.keys.first]; - } - - if (encoder != null) { - outHeaders['content-encoding'] = key; - break; - } - } - } - } - - void _wh(String k, String v) { - // var vv =Uri.encodeComponent(v); - var vv = v; - var headerLine = utf8.encode('$k: $vv').followedBy([$cr, $lf]); - writeToNativeSocket( - rawResponse, Uint8List.fromList(headerLine.toList())); - } - - outHeaders.forEach(_wh); - - for (var c in cookies) { - _wh('set-cookie', c.toString()); - } - - writeToNativeSocket(rawResponse, Uint8List.fromList([$cr, $lf])); - - //_isClosed = true; - return _streamInitialized = true; - } - - return false; - } - - @override - Future addStream(Stream> stream) { - if (_isClosed && isBuffered) throw ResponseContext.closed(); - _openStream(); - - var output = stream; - - if (encoders.isNotEmpty && correspondingRequest != null) { - if (_allowedEncodings != null) { - for (var encodingName in _allowedEncodings!) { - Converter, List>? encoder; - var key = encodingName; - - if (encoders.containsKey(encodingName)) { - encoder = encoders[encodingName]; - } else if (encodingName == '*') { - encoder = encoders[key = encoders.keys.first]; - } - - if (encoder != null) { - output = encoders[key]!.bind(output); - break; - } - } - } - } - - return output.forEach((buf) { - if (!_isClosed) { - writeToNativeSocket( - rawResponse, buf is Uint8List ? buf : Uint8List.fromList(buf)); - } - }); - } - - @override - void add(List data) { - if (_isClosed && isBuffered) { - throw ResponseContext.closed(); - } else if (!isBuffered) { - if (!_isClosed) { - _openStream(); - - if (encoders.isNotEmpty && correspondingRequest != null) { - if (_allowedEncodings != null) { - for (var encodingName in _allowedEncodings!) { - Converter, List>? encoder; - var key = encodingName; - - if (encoders.containsKey(encodingName)) { - encoder = encoders[encodingName]; - } else if (encodingName == '*') { - encoder = encoders[key = encoders.keys.first]; - } - - if (encoder != null) { - data = encoders[key]!.convert(data); - break; - } - } - } - } - - writeToNativeSocket( - rawResponse, data is Uint8List ? data : Uint8List.fromList(data)); - } - } else { - buffer!.add(data); - } - } - - @override - Future close() async { - if (!_isDetached) { - if (!_isClosed) { - _isClosed = true; - if (!isBuffered) { - _openStream(); - closeNativeSocketDescriptor(rawResponse); - } else { - _buffer!.lock(); - } - } - - await correspondingRequest?.close(); - await super.close(); - } - } - - @override - BytesBuilder? get buffer => _buffer; - - @override - int detach() { - _isDetached = true; - return rawResponse!; - } - - @override - bool get isBuffered => _buffer != null; - - @override - bool get isOpen => !_isClosed && !_isDetached; - - @override - void useBuffer() { - _buffer = LockableBytesBuilder(); - } -} diff --git a/archived_packages/wings/lib/src/wings_socket.cc b/archived_packages/wings/lib/src/wings_socket.cc deleted file mode 100644 index 7105b2ee..00000000 --- a/archived_packages/wings/lib/src/wings_socket.cc +++ /dev/null @@ -1,129 +0,0 @@ -#include "wings_socket.h" -#include -#include -#include -using namespace wings; - -std::vector wings::globalSocketList; - -bool WingsSocketInfo::equals(const WingsSocketInfo &right) const { - // std::cout << address << " vs " << right.address << std::endl; - // std::cout << port << " vs " << right.port << std::endl; - return (strcmp(address, right.address) == 0) && port == right.port; -} - -WingsSocket::WingsSocket(sa_family_t family, int sockfd, - const WingsSocketInfo &info) - : sockfd(sockfd), info(info), family(family) { - portIterator = sendPorts.begin(); - open = true; - refCount = 0; - workerThread = nullptr; - this->info.address = strdup(info.address); -} - -void WingsSocket::incrRef(Dart_Port port) { - refCount++; - sendPorts.push_back(port); -} - -void WingsSocket::decrRef(Dart_Port port) { - auto it = std::find(sendPorts.begin(), sendPorts.end(), port); - - if (it != sendPorts.end()) { - sendPorts.erase(it); - } - - refCount--; - - if (refCount <= 0 && open) { - close(sockfd); - open = false; - } -} - -Dart_Port WingsSocket::nextPort() { - portIterator++; - if (portIterator == sendPorts.end()) - portIterator = sendPorts.begin(); - return *portIterator; -} - -const WingsSocketInfo &WingsSocket::getInfo() const { return info; } - -int WingsSocket::getFD() const { return sockfd; } - -sa_family_t WingsSocket::getFamily() const { return family; } - -bool WingsSocket::isClosed() const { return !open; } - -void WingsSocket::start(Dart_NativeArguments arguments) { - // if (workerThread == nullptr) - // { - // workerThread = std::make_unique(threadCallback, this); - // } - Dart_Port service_port = - Dart_NewNativePort("WingsThreadCallback", &threadCallback, true); - Dart_Handle send_port = Dart_NewSendPort(service_port); - Dart_SetReturnValue(arguments, send_port); -} - -void WingsSocket::threadCallback(Dart_Port dest_port_id, - Dart_CObject *message) { - - WingsSocket *socket = nullptr; - Dart_Port outPort = message->value.as_array.values[0]->value.as_send_port.id; - Dart_CObject *ptrArg = message->value.as_array.values[1]; - - // If there are no listeners, quit. - if (ptrArg->type == Dart_CObject_kInt32) { - auto as64 = (int64_t)ptrArg->value.as_int32; - socket = (WingsSocket *)as64; - } else { - socket = (WingsSocket *)ptrArg->value.as_int64; - } - - if (socket != nullptr) { - if (socket->sendPorts.empty() || socket->isClosed()) { - return; - } - - int sock; - unsigned long index = 0; - sockaddr addr; - socklen_t len; - - if ((sock = accept(socket->sockfd, &addr, &len)) != -1) { - char addrBuf[INET6_ADDRSTRLEN] = {0}; - - if (addr.sa_family == AF_INET6) { - auto as6 = (sockaddr_in6 *)&addr; - inet_ntop(addr.sa_family, &(as6->sin6_addr), addrBuf, len); - } else { - auto as4 = (sockaddr_in *)&addr; - inet_ntop(AF_INET, &(as4->sin_addr), addrBuf, len); - } - - Dart_CObject fdObj; - fdObj.type = Dart_CObject_kInt64; - fdObj.value.as_int64 = sock; - - Dart_CObject addrObj; - addrObj.type = Dart_CObject_kString; - addrObj.value.as_string = addrBuf; - - Dart_CObject *values[2] = {&fdObj, &addrObj}; - - Dart_CObject obj; - obj.type = Dart_CObject_kArray; - obj.value.as_array.length = 2; - obj.value.as_array.values = values; - - // Dart_PostCObject(outPort, &obj); - // Dispatch the fd to the next listener. - auto port = socket->nextPort(); - Dart_PostCObject(port, &obj); - // Dart_PostCObject(outPort, &obj); - } - } -} \ No newline at end of file diff --git a/archived_packages/wings/lib/src/wings_socket.dart b/archived_packages/wings/lib/src/wings_socket.dart deleted file mode 100644 index 303459fe..00000000 --- a/archived_packages/wings/lib/src/wings_socket.dart +++ /dev/null @@ -1,130 +0,0 @@ -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; -import 'dart:typed_data'; -import 'dart-ext:angel_wings'; - -int bindWingsIPv4ServerSocket( - String address, - int port, - bool shared, - int backlog, - bool v6Only, - SendPort sendPort) native 'Dart_WingsSocket_bindIPv4'; - -int bindWingsIPv6ServerSocket( - String address, - int port, - bool shared, - int backlog, - bool v6Only, - SendPort sendPort) native 'Dart_WingsSocket_bindIPv6'; - -String getWingsServerSocketAddress(int pointer) - native 'Dart_WingsSocket_getAddress'; - -int getWingsServerSocketPort(int pointer) native 'Dart_WingsSocket_getPort'; - -void writeToNativeSocket(int? fd, Uint8List data) - native 'Dart_WingsSocket_write'; - -void closeNativeSocketDescriptor(int? fd) - native 'Dart_WingsSocket_closeDescriptor'; - -SendPort wingsSocketListen(int pointer) native 'Dart_WingsSocket_listen'; - -void closeWingsSocket(int pointer, SendPort sendPort) - native 'Dart_WingsSocket_close'; - -SendPort wingsParseHttp() native 'Dart_WingsSocket_parseHttp'; - -class WingsClientSocket { - final int? fileDescriptor; - final InternetAddress remoteAddress; - - WingsClientSocket(this.fileDescriptor, this.remoteAddress); -} - -class WingsSocket extends Stream { - final StreamController _ctrl = StreamController(); - late SendPort _acceptor; - InternetAddress? _address; - final int _pointer; - final RawReceivePort _recv; - bool _open = true; - int? _port; - - WingsSocket._(this._pointer, this._recv) { - _acceptor = wingsSocketListen(_pointer); - _recv.handler = (h) { - if (!_ctrl.isClosed) { - _ctrl.add( - WingsClientSocket(h[0] as int?, InternetAddress(h[1] as String))); - _acceptor.send([_recv.sendPort, _pointer]); - } - }; - - _acceptor.send([_recv.sendPort, _pointer]); - } - - static Future bind(address, int port, - {bool shared = false, int backlog = 0, bool v6Only = false}) async { - var recv = RawReceivePort(); - int ptr; - InternetAddress addr; - - if (address is InternetAddress) { - addr = address; - } else if (address is String) { - var addrs = await InternetAddress.lookup(address); - if (addrs.isNotEmpty) { - addr = addrs[0]; - } else { - throw StateError('Internet address lookup failed: $address'); - } - } else { - throw ArgumentError.value( - address, 'address', 'must be an InternetAddress or String'); - } - - try { - if (addr.type == InternetAddressType.IPv6) { - ptr = bindWingsIPv6ServerSocket( - addr.address, port, shared, backlog, v6Only, recv.sendPort); - } else { - ptr = bindWingsIPv4ServerSocket( - addr.address, port, shared, backlog, v6Only, recv.sendPort); - } - - return WingsSocket._(ptr, recv); //.._address = addr; - } catch (e) { - recv.close(); - rethrow; - } - } - - InternetAddress get address => - _address ??= InternetAddress(getWingsServerSocketAddress(_pointer)); - - int get port => _port ??= getWingsServerSocketPort(_pointer); - - @override - StreamSubscription listen( - void Function(WingsClientSocket event)? onData, - {Function? onError, - void Function()? onDone, - bool? cancelOnError}) { - return _ctrl.stream - .listen(onData, onError: onError, cancelOnError: cancelOnError); - } - - Future close(){ - if (_open) { - _open = false; - closeWingsSocket(_pointer, _recv.sendPort); - _recv.close(); - _ctrl.close(); - } - return Future.value(); - } -} diff --git a/archived_packages/wings/lib/src/wings_socket.h b/archived_packages/wings/lib/src/wings_socket.h deleted file mode 100644 index 37336917..00000000 --- a/archived_packages/wings/lib/src/wings_socket.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef WINGS_SOCKET_H -#define WINGS_SOCKET_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace wings { -struct WingsSocketInfo { - const char *address; - uint64_t port; - bool shared; - uint64_t backlog; - bool v6Only; - Dart_Handle sendPortHandle; - bool equals(const WingsSocketInfo &right) const; -}; - -class WingsSocket { -public: - WingsSocket(sa_family_t family, int sockfd, const WingsSocketInfo &info); - void incrRef(Dart_Port port); - void decrRef(Dart_Port port); - const WingsSocketInfo &getInfo() const; - void start(Dart_NativeArguments arguments); - int getFD() const; - bool isClosed() const; - sa_family_t getFamily() const; - Dart_Port nextPort(); - -private: - static void threadCallback(Dart_Port dest_port_id, Dart_CObject *message); - WingsSocketInfo info; - std::list::iterator portIterator; - int sockfd; - int refCount; - bool open; - sa_family_t family; - std::unique_ptr workerThread; - std::list sendPorts; -}; - -extern std::vector globalSocketList; -} // namespace wings - -#endif \ No newline at end of file diff --git a/archived_packages/wings/libangel_wings.dylib b/archived_packages/wings/libangel_wings.dylib deleted file mode 100644 index fbcfc381..00000000 Binary files a/archived_packages/wings/libangel_wings.dylib and /dev/null differ diff --git a/archived_packages/wings/libangel_wings.so b/archived_packages/wings/libangel_wings.so deleted file mode 100644 index 92b8f107..00000000 Binary files a/archived_packages/wings/libangel_wings.so and /dev/null differ diff --git a/archived_packages/wings/provision.sh b/archived_packages/wings/provision.sh deleted file mode 100644 index 345eb439..00000000 --- a/archived_packages/wings/provision.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# Install Dart, globally. -sudo apt-get update -sudo apt-get install apt-transport-https -sudo sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' -sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list' -sudo apt-get update -sudo apt-get install -y dart -export PATH="$PATH:/usr/lib/dart/bin" -echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~vagrant/.profile - -# Install build tooling, CMake, etc. -sudo apt-get install -y build-essential -sudo apt-get install -y cmake - -# Build the library. -pushd /vagrant -mkdir -p cmake-build-vagrant -pushd cmake-build-vagrant -cmake .. -cmake --build . --target install -popd -popd diff --git a/archived_packages/wings/pubspec.yaml b/archived_packages/wings/pubspec.yaml deleted file mode 100644 index b21d79a3..00000000 --- a/archived_packages/wings/pubspec.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: angel_wings -version: 1.0.0 -description: Native HTTP driver for Angel, for a nice speed boost. -homepage: https://github.com/angel-dart/wings -publish_to: none -environment: - sdk: '>=2.12.0 <3.0.0' -dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework - mock_request: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/mock_request -dev_dependencies: - angel_static: #^2.0.0 - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/static - io: ^1.0.0 - lints: ^1.0.0 - pretty_logging: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/pretty_logging diff --git a/archived_packages/wings/ubuntu-bionic-18.04-cloudimg-console.log b/archived_packages/wings/ubuntu-bionic-18.04-cloudimg-console.log deleted file mode 100644 index 63e6554b..00000000 --- a/archived_packages/wings/ubuntu-bionic-18.04-cloudimg-console.log +++ /dev/null @@ -1,672 +0,0 @@ -[ 0.000000] Linux version 4.15.0-60-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 (Ubuntu 4.15.0-60.67-generic 4.15.18) -[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-60-generic root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0 -[ 0.000000] KERNEL supported cpus: -[ 0.000000] Intel GenuineIntel -[ 0.000000] AMD AuthenticAMD -[ 0.000000] Centaur CentaurHauls -[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers' -[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' -[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' -[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256 -[ 0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format. -[ 0.000000] e820: BIOS-provided physical RAM map: -[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable -[ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved -[ 0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved -[ 0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000003ffeffff] usable -[ 0.000000] BIOS-e820: [mem 0x000000003fff0000-0x000000003fffffff] ACPI data -[ 0.000000] BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved -[ 0.000000] BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved -[ 0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved -[ 0.000000] NX (Execute Disable) protection: active -[ 0.000000] SMBIOS 2.5 present. -[ 0.000000] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 -[ 0.000000] Hypervisor detected: KVM -[ 0.000000] e820: last_pfn = 0x3fff0 max_arch_pfn = 0x400000000 -[ 0.000000] MTRR: Disabled -[ 0.000000] x86/PAT: MTRRs disabled, skipping PAT initialization too. -[ 0.000000] CPU MTRRs all blank - virtualized system. -[ 0.000000] x86/PAT: Configuration [0-7]: WB WT UC- UC WB WT UC- UC -[ 0.000000] found SMP MP-table at [mem 0x0009fff0-0x0009ffff] -[ 0.000000] Scanning 1 areas for low memory corruption -[ 0.000000] RAMDISK: [mem 0x35a8b000-0x36d3cfff] -[ 0.000000] ACPI: Early table checksum verification disabled -[ 0.000000] ACPI: RSDP 0x00000000000E0000 000024 (v02 VBOX ) -[ 0.000000] ACPI: XSDT 0x000000003FFF0030 00003C (v01 VBOX VBOXXSDT 00000001 ASL 00000061) -[ 0.000000] ACPI: FACP 0x000000003FFF00F0 0000F4 (v04 VBOX VBOXFACP 00000001 ASL 00000061) -[ 0.000000] ACPI: DSDT 0x000000003FFF0470 0022EA (v02 VBOX VBOXBIOS 00000002 INTL 20100528) -[ 0.000000] ACPI: FACS 0x000000003FFF0200 000040 -[ 0.000000] ACPI: FACS 0x000000003FFF0200 000040 -[ 0.000000] ACPI: APIC 0x000000003FFF0240 00005C (v02 VBOX VBOXAPIC 00000001 ASL 00000061) -[ 0.000000] ACPI: SSDT 0x000000003FFF02A0 0001CC (v01 VBOX VBOXCPUT 00000002 INTL 20100528) -[ 0.000000] No NUMA configuration found -[ 0.000000] Faking a node at [mem 0x0000000000000000-0x000000003ffeffff] -[ 0.000000] NODE_DATA(0) allocated [mem 0x3ffc5000-0x3ffeffff] -[ 0.000000] kvm-clock: cpu 0, msr 0:3ff44001, primary cpu clock -[ 0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00 -[ 0.000000] kvm-clock: using sched offset of 6313796290 cycles -[ 0.000000] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns -[ 0.000000] Zone ranges: -[ 0.000000] DMA [mem 0x0000000000001000-0x0000000000ffffff] -[ 0.000000] DMA32 [mem 0x0000000001000000-0x000000003ffeffff] -[ 0.000000] Normal empty -[ 0.000000] Device empty -[ 0.000000] Movable zone start for each node -[ 0.000000] Early memory node ranges -[ 0.000000] node 0: [mem 0x0000000000001000-0x000000000009efff] -[ 0.000000] node 0: [mem 0x0000000000100000-0x000000003ffeffff] -[ 0.000000] Reserved but unavailable: 98 pages -[ 0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x000000003ffeffff] -[ 0.000000] ACPI: PM-Timer IO Port: 0x4008 -[ 0.000000] IOAPIC[0]: apic_id 2, version 32, address 0xfec00000, GSI 0-23 -[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl) -[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level) -[ 0.000000] Using ACPI (MADT) for SMP configuration information -[ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs -[ 0.000000] PM: Registered nosave memory: [mem 0x00000000-0x00000fff] -[ 0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x0009ffff] -[ 0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000effff] -[ 0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff] -[ 0.000000] e820: [mem 0x40000000-0xfebfffff] available for PCI devices -[ 0.000000] Booting paravirtualized kernel on KVM -[ 0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns -[ 0.000000] random: get_random_bytes called from start_kernel+0x99/0x4fd with crng_init=0 -[ 0.000000] setup_percpu: NR_CPUS:8192 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1 -[ 0.000000] percpu: Embedded 46 pages/cpu s151552 r8192 d28672 u1048576 -[ 0.000000] PV qspinlock hash table entries: 256 (order: 0, 4096 bytes) -[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 257913 -[ 0.000000] Policy zone: DMA32 -[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-60-generic root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0 -[ 0.000000] Memory: 983440K/1048120K available (12300K kernel code, 2481K rwdata, 4172K rodata, 2436K init, 2384K bss, 64680K reserved, 0K cma-reserved) -[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1 -[ 0.000000] Kernel/User page tables isolation: enabled -[ 0.000000] ftrace: allocating 39306 entries in 154 pages -[ 0.004000] Hierarchical RCU implementation. -[ 0.004000] RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=2. -[ 0.004000] Tasks RCU enabled. -[ 0.004000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2 -[ 0.004000] NR_IRQS: 524544, nr_irqs: 440, preallocated irqs: 16 -[ 0.004000] Console: colour VGA+ 80x25 -[ 0.004000] console [tty1] enabled -[ 0.004000] console [ttyS0] enabled -[ 0.004000] ACPI: Core revision 20170831 -[ 0.004000] ACPI: 2 ACPI AML tables successfully acquired and loaded -[ 0.004000] APIC: Switch to symmetric I/O mode setup -[ 0.004000] x2apic enabled -[ 0.004000] Switched APIC routing to physical x2apic. -[ 0.005261] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 -[ 0.008004] tsc: Detected 1799.999 MHz processor -[ 0.012012] Calibrating delay loop (skipped) preset value.. 3599.99 BogoMIPS (lpj=7199996) -[ 0.014430] pid_max: default: 32768 minimum: 301 -[ 0.016036] Security Framework initialized -[ 0.017257] Yama: becoming mindful. -[ 0.018593] AppArmor: AppArmor initialized -[ 0.021844] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes) -[ 0.024088] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes) -[ 0.028022] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes) -[ 0.030085] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes) -[ 0.032346] Last level iTLB entries: 4KB 64, 2MB 8, 4MB 8 -[ 0.036002] Last level dTLB entries: 4KB 64, 2MB 0, 4MB 0, 1GB 4 -[ 0.038331] Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization -[ 0.040053] Spectre V2 : Mitigation: Full generic retpoline -[ 0.044003] Spectre V2 : Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch -[ 0.047370] Speculative Store Bypass: Vulnerable -[ 0.048050] MDS: Vulnerable: Clear CPU buffers attempted, no microcode -[ 0.050738] Freeing SMP alternatives memory: 36K -[ 0.060000] smpboot: CPU0: Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz (family: 0x6, model: 0x3d, stepping: 0x4) -[ 0.060095] Performance Events: unsupported p6 CPU model 61 no PMU driver, software events only. -[ 0.063096] Hierarchical SRCU implementation. -[ 0.064650] NMI watchdog: Perf event create on CPU 0 failed with -2 -[ 0.066472] NMI watchdog: Perf NMI watchdog permanently disabled -[ 0.068053] smp: Bringing up secondary CPUs ... -[ 0.069490] x86: Booting SMP configuration: -[ 0.070770] .... node #0, CPUs: #1 -[ 0.004000] kvm-clock: cpu 1, msr 0:3ff44041, secondary cpu clock -[ 0.078095] smp: Brought up 1 node, 2 CPUs -[ 0.078095] smpboot: Max logical packages: 1 -[ 0.080007] smpboot: Total of 2 processors activated (7199.99 BogoMIPS) -[ 0.085029] devtmpfs: initialized -[ 0.085718] x86/mm: Memory block size: 128MB -[ 0.088152] evm: security.selinux -[ 0.089578] evm: security.SMACK64 -[ 0.090723] evm: security.SMACK64EXEC -[ 0.092005] evm: security.SMACK64TRANSMUTE -[ 0.093324] evm: security.SMACK64MMAP -[ 0.094789] evm: security.apparmor -[ 0.096003] evm: security.ima -[ 0.097270] evm: security.capability -[ 0.100127] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns -[ 0.104010] futex hash table entries: 512 (order: 3, 32768 bytes) -[ 0.108000] pinctrl core: initialized pinctrl subsystem -[ 0.108153] RTC time: 4:37:25, date: 09/29/19 -[ 0.112223] NET: Registered protocol family 16 -[ 0.114097] audit: initializing netlink subsys (disabled) -[ 0.116040] audit: type=2000 audit(1569731852.938:1): state=initialized audit_enabled=0 res=1 -[ 0.120020] cpuidle: using governor ladder -[ 0.121972] cpuidle: using governor menu -[ 0.124054] ACPI: bus type PCI registered -[ 0.125660] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 -[ 0.128144] PCI: Using configuration type 1 for base access -[ 0.132420] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages -[ 0.136070] ACPI: Added _OSI(Module Device) -[ 0.137755] ACPI: Added _OSI(Processor Device) -[ 0.139558] ACPI: Added _OSI(3.0 _SCP Extensions) -[ 0.140012] ACPI: Added _OSI(Processor Aggregator Device) -[ 0.142205] ACPI: Added _OSI(Linux-Dell-Video) -[ 0.144009] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio) -[ 0.146265] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics) -[ 0.148559] ACPI: Executed 1 blocks of module-level executable AML code -[ 0.157460] ACPI: Interpreter enabled -[ 0.159031] ACPI: (supports S0 S5) -[ 0.160004] ACPI: Using IOAPIC for interrupt routing -[ 0.162232] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug -[ 0.164282] ACPI: Enabled 2 GPEs in block 00 to 07 -[ 0.177420] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff]) -[ 0.179619] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI] -[ 0.180559] acpi PNP0A03:00: _OSC: not requesting OS control; OS requires [ExtendedConfig ASPM ClockPM MSI] -[ 0.184016] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge. -[ 0.188599] PCI host bridge to bus 0000:00 -[ 0.190032] pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7 window] -[ 0.192012] pci_bus 0000:00: root bus resource [io 0x0d00-0xffff window] -[ 0.196010] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window] -[ 0.198997] pci_bus 0000:00: root bus resource [mem 0x40000000-0xfdffffff window] -[ 0.200005] pci_bus 0000:00: root bus resource [bus 00-ff] -[ 0.209096] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io 0x01f0-0x01f7] -[ 0.212011] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io 0x03f6] -[ 0.214198] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io 0x0170-0x0177] -[ 0.216011] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io 0x0376] -[ 0.250063] pci 0000:00:07.0: quirk: [io 0x4000-0x403f] claimed by PIIX4 ACPI -[ 0.252032] pci 0000:00:07.0: quirk: [io 0x4100-0x410f] claimed by PIIX4 SMB -[ 0.268428] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 9 10 *11) -[ 0.271342] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 9 *10 11) -[ 0.272177] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 *9 10 11) -[ 0.274371] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 9 10 *11) -[ 0.276529] SCSI subsystem initialized -[ 0.280075] pci 0000:00:02.0: vgaarb: setting as boot VGA device -[ 0.282678] pci 0000:00:02.0: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none -[ 0.284008] pci 0000:00:02.0: vgaarb: bridge control possible -[ 0.288007] vgaarb: loaded -[ 0.289501] ACPI: bus type USB registered -[ 0.292045] usbcore: registered new interface driver usbfs -[ 0.294316] usbcore: registered new interface driver hub -[ 0.296044] usbcore: registered new device driver usb -[ 0.300127] EDAC MC: Ver: 3.0.0 -[ 0.302311] PCI: Using ACPI for IRQ routing -[ 0.304830] NetLabel: Initializing -[ 0.308006] NetLabel: domain hash size = 128 -[ 0.310637] NetLabel: protocols = UNLABELED CIPSOv4 CALIPSO -[ 0.312043] NetLabel: unlabeled traffic allowed by default -[ 0.316129] clocksource: Switched to clocksource kvm-clock -[ 0.338523] VFS: Disk quotas dquot_6.6.0 -[ 0.340526] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes) -[ 0.344063] AppArmor: AppArmor Filesystem Enabled -[ 0.347415] pnp: PnP ACPI init -[ 0.354536] pnp: PnP ACPI: found 3 devices -[ 0.377986] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns -[ 0.384610] NET: Registered protocol family 2 -[ 0.391662] TCP established hash table entries: 8192 (order: 4, 65536 bytes) -[ 0.396743] TCP bind hash table entries: 8192 (order: 5, 131072 bytes) -[ 0.401916] TCP: Hash tables configured (established 8192 bind 8192) -[ 0.406238] UDP hash table entries: 512 (order: 2, 16384 bytes) -[ 0.409854] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) -[ 0.414792] NET: Registered protocol family 1 -[ 0.418002] pci 0000:00:00.0: Limiting direct PCI/PCI transfers -[ 0.423100] pci 0000:00:01.0: Activating ISA DMA hang workarounds -[ 0.427601] pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff] -[ 0.434649] Unpacking initramfs... -[ 0.787407] Freeing initrd memory: 19144K -[ 0.789209] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x19f228ab7a2, max_idle_ns: 440795289252 ns -[ 0.793332] platform rtc_cmos: registered platform RTC device (no PNP device found) -[ 0.796800] Scanning for low memory corruption every 60 seconds -[ 0.799238] Initialise system trusted keyrings -[ 0.801081] Key type blacklist registered -[ 0.802821] workingset: timestamp_bits=36 max_order=18 bucket_order=0 -[ 0.805819] zbud: loaded -[ 0.807186] squashfs: version 4.0 (2009/01/31) Phillip Lougher -[ 0.810037] fuse init (API version 7.26) -[ 0.815469] Key type asymmetric registered -[ 0.816858] Asymmetric key parser 'x509' registered -[ 0.818479] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246) -[ 0.821254] io scheduler noop registered -[ 0.822470] io scheduler deadline registered -[ 0.823827] io scheduler cfq registered (default) -[ 0.826132] ACPI: AC Adapter [AC] (on-line) -[ 0.827462] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 -[ 0.830032] ACPI: Power Button [PWRF] -[ 0.831785] input: Sleep Button as /devices/LNXSYSTM:00/LNXSLPBN:00/input/input1 -[ 0.834809] ACPI: Sleep Button [SLPF] -[ 0.838210] ACPI: Battery Slot [BAT0] (battery present) -[ 0.840233] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled - -  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~[ 0.869459] 00:02: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A -[ 0.873870] Linux agpgart interface v0.103 -[ 0.876700] loop: module loaded -[ 0.878775] scsi host0: ata_piix -[ 0.880366] scsi host1: ata_piix -[ 0.881737] ata1: PATA max UDMA/33 cmd 0x1f0 ctl 0x3f6 bmdma 0xd000 irq 14 -[ 0.883885] ata2: PATA max UDMA/33 cmd 0x170 ctl 0x376 bmdma 0xd008 irq 15 -[ 0.886091] libphy: Fixed MDIO Bus: probed -[ 0.887767] tun: Universal TUN/TAP device driver, 1.6 -[ 0.889455] PPP generic driver version 2.4.2 -[ 0.890748] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver -[ 0.892752] ehci-pci: EHCI PCI platform driver -[ 0.894121] ehci-platform: EHCI generic platform driver -[ 0.895894] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver -[ 0.898361] ohci-pci: OHCI PCI platform driver -[ 0.900140] ohci-platform: OHCI generic platform driver -[ 0.902441] uhci_hcd: USB Universal Host Controller Interface driver -[ 0.904865] i8042: PNP: PS/2 Controller [PNP0303:PS2K,PNP0f03:PS2M] at 0x60,0x64 irq 1,12 -[ 0.907797] serio: i8042 KBD port at 0x60,0x64 irq 1 -[ 0.909401] serio: i8042 AUX port at 0x60,0x64 irq 12 -[ 0.910962] mousedev: PS/2 mouse device common for all mice -[ 0.913441] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input2 -[ 0.916486] rtc_cmos rtc_cmos: rtc core: registered rtc_cmos as rtc0 -[ 0.918365] rtc_cmos rtc_cmos: alarms up to one day, 114 bytes nvram -[ 0.920021] i2c /dev entries driver -[ 0.921365] device-mapper: uevent: version 1.0.3 -[ 0.922803] device-mapper: ioctl: 4.37.0-ioctl (2017-09-20) initialised: dm-devel@redhat.com -[ 0.926126] ledtrig-cpu: registered to indicate activity on CPUs -[ 0.929176] NET: Registered protocol family 10 -[ 0.937552] Segment Routing with IPv6 -[ 0.938709] NET: Registered protocol family 17 -[ 0.940188] Key type dns_resolver registered -[ 0.941836] mce: Using 0 MCE banks -[ 0.943170] RAS: Correctable Errors collector initialized. -[ 0.945569] sched_clock: Marking stable (945543331, 0)->(1319832110, -374288779) -[ 0.948649] registered taskstats version 1 -[ 0.949901] Loading compiled-in X.509 certificates -[ 0.954626] Loaded X.509 cert 'Build time autogenerated kernel key: 9d88e3c0462fa0d2df2917e8bbfdfdd1c55d8ddc' -[ 0.958110] zswap: loaded using pool lzo/zbud -[ 0.964498] Key type big_key registered -[ 0.965808] Key type trusted registered -[ 0.969372] Key type encrypted registered -[ 0.970893] AppArmor: AppArmor sha1 policy hashing enabled -[ 0.973159] ima: No TPM chip found, activating TPM-bypass! (rc=-19) -[ 0.975617] ima: Allocated hash algorithm: sha1 -[ 0.977534] evm: HMAC attrs: 0x1 -[ 0.979719] Magic number: 3:202:617 -[ 0.982579] rtc_cmos rtc_cmos: setting system clock to 2019-09-29 04:37:26 UTC (1569731846) -[ 0.986467] BIOS EDD facility v0.16 2004-Jun-25, 0 devices found -[ 0.988892] EDD information not available. -[ 1.049273] Freeing unused kernel image memory: 2436K -[ 1.064568] Write protecting the kernel read-only data: 20480k -[ 1.067065] Freeing unused kernel image memory: 2008K -[ 1.069111] Freeing unused kernel image memory: 1972K -[ 1.077828] x86/mm: Checked W+X mappings: passed, no W+X pages found. -[ 1.080111] x86/mm: Checking user space page tables -[ 1.089009] x86/mm: Checked W+X mappings: passed, no W+X pages found. -Loading, please wait... -starting version 237 -[ 1.184353] Fusion MPT base driver 3.04.20 -[ 1.186024] Copyright (c) 1999-2008 LSI Corporation -[ 1.196999] e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI -[ 1.199908] e1000: Copyright (c) 1999-2006 Intel Corporation. -[ 1.208654] Fusion MPT SPI Host driver 3.04.20 -[ 1.224491] AVX2 version of gcm_enc/dec engaged. -[ 1.231798] AES CTR mode by8 optimization enabled -[ 1.419237] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input4 -[ 1.843515] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 02:ee:0a:3b:45:98 -[ 1.846823] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection -[ 1.851174] mptbase: ioc0: Initiating bringup -[ 1.851551] e1000 0000:00:03.0 enp0s3: renamed from eth0 -[ 1.952561] ioc0: LSI53C1030 A0: Capabilities={Initiator} -[ 2.195418] scsi host2: ioc0: LSI53C1030 A0, FwRev=00000000h, Ports=1, MaxQ=256, IRQ=20 -[ 2.365548] scsi 2:0:0:0: Direct-Access VBOX HARDDISK 1.0 PQ: 0 ANSI: 5 -[ 2.400288] scsi target2:0:0: Beginning Domain Validation -[ 2.405262] scsi target2:0:0: Domain Validation skipping write tests -[ 2.407797] scsi target2:0:0: Ending Domain Validation -[ 2.410045] scsi target2:0:0: asynchronous -[ 2.413130] scsi 2:0:1:0: Direct-Access VBOX HARDDISK 1.0 PQ: 0 ANSI: 5 -[ 2.444548] scsi target2:0:1: Beginning Domain Validation -[ 2.447997] random: fast init done -[ 2.450934] scsi target2:0:1: Domain Validation skipping write tests -[ 2.453478] scsi target2:0:1: Ending Domain Validation -[ 2.455625] scsi target2:0:1: asynchronous -[ 2.466484] random: systemd-udevd: uninitialized urandom read (16 bytes read) -[ 2.466557] sd 2:0:0:0: Attached scsi generic sg0 type 0 -[ 2.469874] random: systemd-udevd: uninitialized urandom read (16 bytes read) -[ 2.472254] sd 2:0:1:0: Attached scsi generic sg1 type 0 -[ 2.475796] sd 2:0:1:0: [sdb] 20480 512-byte logical blocks: (10.5 MB/10.0 MiB) -[ 2.480854] random: systemd-udevd: uninitialized urandom read (16 bytes read) -[ 2.483694] sd 2:0:1:0: [sdb] Write Protect is off -[ 2.483705] sd 2:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB) -[ 2.491205] sd 2:0:1:0: [sdb] Incomplete mode parameter data -[ 2.496107] sd 2:0:1:0: [sdb] Assuming drive cache: write through -[ 2.496223] sd 2:0:0:0: [sda] Write Protect is off -[ 2.501151] sd 2:0:0:0: [sda] Incomplete mode parameter data -[ 2.503655] sd 2:0:1:0: [sdb] Attached SCSI disk -[ 2.504110] sd 2:0:0:0: [sda] Assuming drive cache: write through -[ 2.512349] sda: sda1 -[ 2.514834] sd 2:0:0:0: [sda] Attached SCSI disk -Begin: Loading essential drivers ... [ 4.120365] raid6: sse2x1 gen() 8070 MB/s -[ 4.168222] raid6: sse2x1 xor() 6016 MB/s -[ 4.216338] raid6: sse2x2 gen() 10374 MB/s -[ 4.264252] raid6: sse2x2 xor() 6295 MB/s -[ 4.312232] raid6: sse2x4 gen() 12057 MB/s -[ 4.360267] raid6: sse2x4 xor() 7732 MB/s -[ 4.408068] raid6: avx2x1 gen() 16441 MB/s -[ 4.456229] raid6: avx2x1 xor() 10055 MB/s -[ 4.504190] raid6: avx2x2 gen() 18760 MB/s -[ 4.552254] raid6: avx2x2 xor() 10226 MB/s -[ 4.600221] raid6: avx2x4 gen() 22732 MB/s -[ 4.648232] raid6: avx2x4 xor() 13132 MB/s -[ 4.649527] raid6: using algorithm avx2x4 gen() 22732 MB/s -[ 4.651588] raid6: .... xor() 13132 MB/s, rmw enabled -[ 4.653647] raid6: using avx2x2 recovery algorithm -[ 4.657327] xor: automatically using best checksumming function avx -[ 4.661178] async_tx: api initialized (async) -done. -Begin: Running /scripts/init-premount ... done. -Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done. -Begin: Running /scripts/local-premount ... [ 4.729105] Btrfs loaded, crc32c=crc32c-intel -Scanning for Btrfs filesystems -done. -Warning: fsck not present, so skipping root file system -[ 4.781118] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null) -done. -Begin: Running /scripts/local-bottom ... done. -Begin: Running /scripts/init-bottom ... done. -[ 5.131768] ip_tables: (C) 2000-2006 Netfilter Core Team -[ 5.152384] systemd[1]: systemd 237 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid) -[ 5.159865] systemd[1]: Detected virtualization oracle. -[ 5.161648] systemd[1]: Detected architecture x86-64. - -Welcome to Ubuntu 18.04.3 LTS! - -[ 5.176478] systemd[1]: Set hostname to . -[ 5.185207] systemd[1]: Initializing machine ID from random generator. -[ 5.187205] systemd[1]: Installed transient /etc/machine-id file. -[ 5.680638] systemd[1]: Reached target User and Group Name Lookups. -[ OK ] Reached target User and Group Name Lookups. -[ 5.686276] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point. -[ OK ] Set up automount Arbitrary Executab…rmats File System Automount Point. -[ 5.698844] systemd[1]: Created slice System Slice. -[ OK ] Created slice System Slice. -[ 5.703202] systemd[1]: Created slice system-serial\x2dgetty.slice. -[ OK ] Created slice system-serial\x2dgetty.slice. -[ OK ] Listening on Journal Socket. -[ OK ] Listening on LVM2 poll daemon socket. - Starting Set the console keyboard layout... - Mounting Kernel Debug File System... - Starting Create list of required st…ce nodes for the current kernel... -[ OK ] Listening on Journal Socket (/dev/log). -[ OK ] Listening on LVM2 metadata daemon socket. - Starting Remount Root and Kernel File Systems... -[ OK ] Listening on Device-mapper event daemon FIFOs. - Starting Monitoring of LVM2 mirrors…ng dmeventd or progress polling... -[ OK ] Listening on Syslog Socket. -[ OK ] Listening on Network Service Netlink Socket. -[ OK ] Listening on udev Kernel Socket. - Starting Load Kernel Modules... -[ OK ] Listening on Journal Audit Socket. - Mounting POSIX Message Queue File System... -[ 5.813826] EXT4-fs (sda1): re-mounted. Opts: (null) - Starting Journal Service... -[ OK ] Listening on udev Control Socket. - Starting udev Coldplug all Devices... - Mounting Huge Pages File System... -[ OK ] Listening on /dev/initctl Compatibility Named Pipe. -[ OK ] Reached target System Time Synchronized. -[ OK ] Reached target Swap. -[ OK ] Started Forward Password Requests to Wall Directory Watch. -[ 5.847175] Loading iSCSI transport class v2.0-870. -[ OK ] Created slice User and Session Slice. -[ OK ] Reached target Slices. - Starting Uncomplicated firewall... -[ OK ] Mounted Kernel Debug File System. -[ OK ] Started Create list of required sta…vice nodes for the current kernel. -[ OK ] Started Remount Root and Kernel File Systems. -[ OK ] Mounted POSIX Message Queue File System. -[ OK ] Mounted Huge Pages File System. -[ OK ] Started LVM2 metadata daemon. - Starting Load/Save Random Seed... -[ 5.940173] iscsi: registered transport (tcp) - Starting Create Static Device Nodes in /dev... -[ OK ] Started Uncomplicated firewall. -[ OK ] Started udev Coldplug all Devices. -[ OK ] Started Load/Save Random Seed. -[ OK ] Started Monitoring of LVM2 mirrors,…sing dmeventd or progress polling. -[ OK ] Started Journal Service. - Starting Flush Journal to Persistent Storage... -[ 6.067247] iscsi: registered transport (iser) -[ OK ] Started Set the console keyboard layout. -[ OK ] Started Load Kernel Modules. - Starting Apply Kernel Variables... - Mounting Kernel Configuration File System... - Mounting FUSE Control File System... -[ OK ] Mounted Kernel Configuration File System. -[ OK ] Mounted FUSE Control File System. -[ 6.097472] systemd-journald[397]: Received request to flush runtime journal from PID 1 -[ OK ] Started Create Static Device Nodes in /dev. -[ OK ] Reached target Local File Systems (Pre). -[ OK ] Reached target Local File Systems. - Starting Set console font and keymap... - Starting AppArmor initialization... - Starting Tell Plymouth To Write Out Runtime Data... - Starting ebtables ruleset management... - Starting Commit a transient machine-id on disk... - Starting udev Kernel Device Manager... -[ OK ] Started Set console font and keymap. -[ OK ] Started Tell Plymouth To Write Out Runtime Data. -[ OK ] Started Apply Kernel Variables. -[ OK ] Started Flush Journal to Persistent Storage. -[ OK ] Started Commit a transient machine-id on disk. - Starting Create Volatile Files and Directories... -[ OK ] Started udev Kernel Device Manager. -[ OK ] Started Dispatch Password Requests to Console Directory Watch. -[ OK ] Reached target Local Encrypted Volumes. -[ OK ] Started Create Volatile Files and Directories. - Starting Update UTMP about System Boot/Shutdown... -[ OK ] Started ebtables ruleset management. -[ OK ] Started Update UTMP about System Boot/Shutdown. -[ OK ] Found device /dev/ttyS0. -[ OK ] Listening on Load/Save RF Kill Switch Status /dev/rfkill Watch. -[ OK ] Started AppArmor initialization. - Starting Initial cloud-init job (pre-networking)... -[ 10.488512] cloud-init[541]: Cloud-init v. 19.1-1-gbaa47854-0ubuntu1~18.04.1 running 'init-local' at Sun, 29 Sep 2019 04:37:35 +0000. Up 10.03 seconds. -[ OK ] Started Initial cloud-init job (pre-networking). -[ OK ] Reached target Network (Pre). - Starting Network Service... -[ OK ] Started Network Service. - Starting Wait for Network to be Configured... - Starting Network Name Resolution... -[ OK ] Started Network Name Resolution. -[ OK ] Reached target Host and Network Name Lookups. -[ OK ] Reached target Network. -[ OK ] Started Wait for Network to be Configured. - Starting Initial cloud-init job (metadata service crawler)... -[ 12.969172] cloud-init[659]: Cloud-init v. 19.1-1-gbaa47854-0ubuntu1~18.04.1 running 'init' at Sun, 29 Sep 2019 04:37:38 +0000. Up 12.79 seconds. -[ 12.988414] cloud-init[659]: ci-info: +++++++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++++++++ -[ 12.994201] cloud-init[659]: ci-info: +--------+------+---------------------------+---------------+--------+-------------------+ -[ 12.999006] cloud-init[659]: ci-info: | Device | Up | Address | Mask | Scope | Hw-Address | -[ 13.004875] cloud-init[659]: ci-info: +--------+------+---------------------------+---------------+--------+-------------------+ -[ 13.020787] cloud-init[659]: ci-info: | enp0s3 | True | 10.0.2.15 | 255.255.255.0 | global | 02:ee:0a:3b:45:98 | -[ 13.025532] cloud-init[659]: ci-info: | enp0s3 | True | fe80::ee:aff:fe3b:4598/64 | . | link | 02:ee:0a:3b:45:98 | -[ 13.031006] cloud-init[659]: ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . | -[ 13.035312] cloud-init[659]: ci-info: | lo | True | ::1/128 | . | host | . | -[ 13.039598] cloud-init[659]: ci-info: +--------+------+---------------------------+---------------+--------+-------------------+ -[ 13.043951] cloud-init[659]: ci-info: ++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++ -[ 13.047653] cloud-init[659]: ci-info: +-------+-------------+----------+-----------------+-----------+-------+ -[ 13.051037] cloud-init[659]: ci-info: | Route | Destination | Gateway | Genmask | Interface | Flags | -[ 13.054622] cloud-init[659]: ci-info: +-------+-------------+----------+-----------------+-----------+-------+ -[ 13.058025] cloud-init[659]: ci-info: | 0 | 0.0.0.0 | 10.0.2.2 | 0.0.0.0 | enp0s3 | UG | -[ 13.064532] cloud-init[659]: ci-info: | 1 | 10.0.2.0 | 0.0.0.0 | 255.255.255.0 | enp0s3 | U | -[ 13.068647] cloud-init[659]: ci-info: | 2 | 10.0.2.2 | 0.0.0.0 | 255.255.255.255 | enp0s3 | UH | -[ 13.072784] cloud-init[659]: ci-info: +-------+-------------+----------+-----------------+-----------+-------+ -[ 13.077092] cloud-init[659]: ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++ -[ 13.081258] cloud-init[659]: ci-info: +-------+-------------+---------+-----------+-------+ -[ 13.084694] cloud-init[659]: ci-info: | Route | Destination | Gateway | Interface | Flags | -[ 13.088479] cloud-init[659]: ci-info: +-------+-------------+---------+-----------+-------+ -[ 13.092360] cloud-init[659]: ci-info: | 1 | fe80::/64 | :: | enp0s3 | U | -[ 13.096047] cloud-init[659]: ci-info: | 3 | local | :: | enp0s3 | U | -[ 13.108512] cloud-init[659]: ci-info: | 4 | ff00::/8 | :: | enp0s3 | U | -[ 13.111402] cloud-init[659]: ci-info: +-------+-------------+---------+-----------+-------+ -[ 14.801704] cloud-init[659]: Generating public/private rsa key pair. -[ 14.804063] cloud-init[659]: Your identification has been saved in /etc/ssh/ssh_host_rsa_key. -[ 14.807013] cloud-init[659]: Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub. -[ 14.810006] cloud-init[659]: The key fingerprint is: -[ 14.811799] cloud-init[659]: SHA256:c2pCGhDRoUfEBnPbtaYdQ3UOxcvdbTfhVuLtz0dkmho root@ubuntu-bionic -[ 14.814850] cloud-init[659]: The key's randomart image is: -[ 14.816758] cloud-init[659]: +---[RSA 2048]----+ -[ 14.818333] cloud-init[659]: | =*=. o.ooo | -[ 14.820006] cloud-init[659]: | *+o o . +. ...| -[ 14.821832] cloud-init[659]: | o.o . = ..+.++| -[ 14.823443] cloud-init[659]: | o + o o o+O| -[ 14.825068] cloud-init[659]: | . o S . .Bo| -[ 14.826979] cloud-init[659]: | + + E o o| -[ 14.828571] cloud-init[659]: | . . o o o.| -[ 14.830148] cloud-init[659]: | o . +| -[ 14.831813] cloud-init[659]: | .| -[ 14.833704] cloud-init[659]: +----[SHA256]-----+ -[ 14.835513] cloud-init[659]: Generating public/private dsa key pair. -[ 14.837922] cloud-init[659]: Your identification has been saved in /etc/ssh/ssh_host_dsa_key. -[ 14.841095] cloud-init[659]: Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub. -[ 14.848419] cloud-init[659]: The key fingerprint is: -[ 14.851284] cloud-init[659]: SHA256:MJXByZgiy2fMsy8Xn2zy9OmXy933B3UshTKr+5h33hk root@ubuntu-bionic -[ 14.855140] cloud-init[659]: The key's randomart image is: -[ 14.857583] cloud-init[659]: +---[DSA 1024]----+ -[ 14.859572] cloud-init[659]: | =o+ . | -[ 14.861674] cloud-init[659]: | . . o.= o . .| -[ 14.864198] cloud-init[659]: | . = .o + o | -[ 14.866677] cloud-init[659]: | o * o . . +| -[ 14.868652] cloud-init[659]: | o o S . o.| -[ 14.870808] cloud-init[659]: | . . . . | -[ 14.873495] cloud-init[659]: | . +.. . . E | -[ 14.875623] cloud-init[659]: | . +.=..=+..o=| -[ 14.877971] cloud-init[659]: | o +..*+++o.B| -[ 14.892804] cloud-init[659]: +----[SHA256]-----+ -[ 14.895209] cloud-init[659]: Generating public/private ecdsa key pair. -[ 14.898389] cloud-init[659]: Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key. -[ 14.902293] cloud-init[659]: Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub. -[ 14.906277] cloud-init[659]: The key fingerprint is: -[ 14.908735] cloud-init[659]: SHA256:pO6EMl9WjroVoRc7HUT6TPHWmIwrLWM7cIAbiERyxQY root@ubuntu-bionic -[ 14.913129] cloud-init[659]: The key's randomart image is: -[ 14.915736] cloud-init[659]: +---[ECDSA 256]---+ -[ 14.917760] cloud-init[659]: |ooE+. .+ | -[ 14.919668] cloud-init[659]: |+o .o o = + | -[ 14.921986] cloud-init[659]: |o o.. + = * . | -[ 14.924110] cloud-init[659]: | o o % + | -[ 14.926792] cloud-init[659]: | . o % S | -[ 14.929165] cloud-init[659]: | B @ | -[ 14.931706] cloud-init[659]: | o . X . | -[ 14.938220] cloud-init[659]: | + B . | -[ 14.940944] cloud-init[659]: | +.. | -[ OK ] Started Initial cloud-init job (metadata service crawler). -[ 14.968369] cloud-init[659]: +----[SHA256]-----+ -[ 14.970927] cloud-init[659]: Generating public/private ed25519 key pair. -[ 14.973333] cloud-init[659]: Your identification has been saved in /etc/ssh/ssh_host_ed25519_key.[ OK ] Reached target Cloud-config availability. -[ OK ] Reached target Network is Online. - -[ 14.985253] cloud-init[659]: Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub. -[ 14.988429] cloud-init[659]: The key fingerprint is: -[ 14.990670] cloud-init[659]: SHA256:DRCkk4eijXFIbhkPmPoF+gSbJ3ncPFySperwkyCRpI0 root@ubuntu-bionic[ OK ] Reached target Remote File Systems (Pre). -[ OK ] Reached target Remote File Systems. - - Starting Availability of block devices... -[ 15.016115] cloud-init[659]: The key's randomart image is: -[ OK ] Reached target System Initialization. -[ OK ] Started Daily apt download activities. -[ OK [ 15.018265] cloud-init[659]: +--[ED25519 256]--+ -] Started Daily Cleanup of Temporary Directories. -[ 15.034267] cloud-init[659]: |.* +=. | -[ 15.035916] cloud-init[659]: |O=* o=.. | Starting LXD - unix socket. -[ OK ] Listening on D-Bus System Message Bus Socket. -[ OK ] Started ACPI Events Check. -[ OK ] Listening on ACPID Listen Socket. -[ OK ] Started Daily apt upgrade and clean activities. -[ OK ] Reached target Paths. -[ OK ] Started Discard unused blocks once a week. - Starting Socket activation for snappy daemon. -[ OK ] Listening on UUID daemon activation socket. -[ OK ] Started Message of the Day. -[ OK ] Reached target Timers. -[ OK ] Listening on Open-iSCSI iscsid Socket. - -[ OK ] Started Availability of block devices.[ 15.080554] cloud-init[659]: |E@+**o. . | -[ 15.081867] cloud-init[659]: |OB=o*o o | -[ 15.082301] cloud-init[659]: |*Bo. . S . | -[ 15.082380] cloud-init[659]: |.=o. | -[ 15.082428] cloud-init[659]: | = | -[ 15.082593] cloud-init[659]: | . | -[ 15.082950] cloud-init[659]: | | -[ 15.083005] cloud-init[659]: +----[SHA256]-----+ - -[ OK ] Listening on LXD - unix socket. -[ OK ] Listening on Socket activation for snappy daemon. -[ OK ] Reached target Sockets. -[ OK ] Reached target Basic System. - Starting System Logging Service... -[ OK ] Started FUSE filesystem for LXC. - Starting LSB: Record successful boot for GRUB... - Starting Accounts Service... -[ OK ] Started Regular background program processing daemon. -[ OK ] Started irqbalance daemon. - Starting LSB: automatic crash report generation... -[ OK ] Started D-Bus System Message Bus. - Starting Dispatcher daemon for systemd-networkd... - Starting Permit User Sessions... - Starting LXD - container startup/shutdown... -[ OK ] Started Deferred execution scheduler. - Starting Login Service... - Starting Snappy daemon... - Starting Pollinate to seed the pseudo random number generator... - Starting Virtualbox guest utils... -[ OK ] Started System Logging Service. -[ OK ] Started Permit User Sessions. -[ OK ] Started Login Service. -[ OK ] Started Unattended Upgrades Shutdown. - Starting Authorization Manager... - Starting Hold until boot process finishes up... - Starting Terminate Plymouth Boot Screen... -[ OK ] Started Hold until boot process finishes up. -[ OK ] Started Serial Getty on ttyS0. - Starting Set console scheme... -[ OK ] Started Terminate Plymouth Boot Screen. -[ OK ] Started LSB: automatic crash report generation. -[ OK ] Started Set console scheme. -[ OK ] Created slice system-getty.slice. -[ OK ] Started Getty on tty1. -[ OK ] Reached target Login Prompts. -[ OK ] Started Authorization Manager. -[ OK ] Started Accounts Service. -[ OK ] Started LSB: Record successful boot for GRUB. -[ OK ] Started Virtualbox guest utils. -[ OK ] Started Dispatcher daemon for systemd-networkd. -[ OK ] Started LXD - container startup/shutdown. -[ OK ] Started Snappy daemon. - Starting Wait until snapd is fully seeded... -[ OK ] Started Pollinate to seed the pseudo random number generator. - Starting OpenBSD Secure Shell server... -[ OK ] Started OpenBSD Secure Shell server. -[ OK ] Created slice User Slice of vagrant. - Starting User Manager for UID 1000... -[ OK ] Started Session 1 of user vagrant. -[ OK ] Started User Manager for UID 1000. -[ OK ] Started Wait until snapd is fully seeded. -[ OK ] Reached target Multi-User System. -[ OK ] Reached target Graphical Interface. - Starting Update UTMP about System Runlevel Changes... - Starting Apply the settings specified in cloud-config... -[ OK ] Started Update UTMP about System Runlevel Changes. - -Ubuntu 18.04.3 LTS ubuntu-bionic ttyS0 - -ubuntu-bionic login: [ 22.238032] cloud-init[1248]: Cloud-init v. 19.1-1-gbaa47854-0ubuntu1~18.04.1 running 'modules:config' at Sun, 29 Sep 2019 04:37:46 +0000. Up 20.92 seconds. -ci-info: no authorized ssh keys fingerprints found for user ubuntu. -<14>Sep 29 04:37:48 ec2: -<14>Sep 29 04:37:48 ec2: ############################################################# -<14>Sep 29 04:37:48 ec2: -----BEGIN SSH HOST KEY FINGERPRINTS----- -<14>Sep 29 04:37:48 ec2: 1024 SHA256:MJXByZgiy2fMsy8Xn2zy9OmXy933B3UshTKr+5h33hk root@ubuntu-bionic (DSA) -<14>Sep 29 04:37:48 ec2: 256 SHA256:pO6EMl9WjroVoRc7HUT6TPHWmIwrLWM7cIAbiERyxQY root@ubuntu-bionic (ECDSA) -<14>Sep 29 04:37:48 ec2: 256 SHA256:DRCkk4eijXFIbhkPmPoF+gSbJ3ncPFySperwkyCRpI0 root@ubuntu-bionic (ED25519) -<14>Sep 29 04:37:48 ec2: 2048 SHA256:c2pCGhDRoUfEBnPbtaYdQ3UOxcvdbTfhVuLtz0dkmho root@ubuntu-bionic (RSA) -<14>Sep 29 04:37:49 ec2: -----END SSH HOST KEY FINGERPRINTS----- -<14>Sep 29 04:37:49 ec2: ############################################################# ------BEGIN SSH HOST KEY KEYS----- -ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBL1FoJIMczy8dfbRV3RzzcLXkRT/ouhH2qd6HDGf+Akmq+66qodZ0SAF24sVKe32obV1l1ajbBfVR5FpXdvZ+l0= root@ubuntu-bionic -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAO/aUSNVrB6FQOHxHf2DXC19OlkZIgLMoAi8iVDNNpN root@ubuntu-bionic -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/EIXVrXLv5Nzfe/cqvE4IBOGjA097OyEJSTB/chiuHlw/YPuVtTsDRDEOSIvjPGsjzQG/PBzgdJx4nnL1+xV2WUVNZvFDQUmXSyCRuAxPZSO9FwkfLb6ebloPoyuojmiMcqFuhb+ZTiGmJwf5LoPzz9xF8qxrsD1IGadfw8GINfhERoQRaP6rM/lPbIQgnwcK03oPlCs35NMAa09nQ4Qs0sUPEjt+IMOCxifCqoCpsHUMT4bU/FFxQ1c9nr39AuCegjILGM6mtMP+Wutgbpg4ZxpJ7e3uO8J5jrTZa9U13bSzpO7JUSJrri1ol5Lsx1w6S5rVZqJhpyNFjIzsdnXR root@ubuntu-bionic ------END SSH HOST KEY KEYS----- -[ 23.573587] cloud-init[1370]: Cloud-init v. 19.1-1-gbaa47854-0ubuntu1~18.04.1 running 'modules:final' at Sun, 29 Sep 2019 04:37:48 +0000. Up 23.13 seconds. -[ 23.573721] cloud-init[1370]: ci-info: no authorized ssh keys fingerprints found for user ubuntu. -[ 23.588105] cloud-init[1370]: Cloud-init v. 19.1-1-gbaa47854-0ubuntu1~18.04.1 finished at Sun, 29 Sep 2019 04:37:49 +0000. Datasource DataSourceNoCloud [seed=/dev/sdb][dsmode=net]. Up 23.54 seconds diff --git a/archived_packages/wings/web/index.html b/archived_packages/wings/web/index.html deleted file mode 100644 index c0300979..00000000 --- a/archived_packages/wings/web/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Angel Wings - - - -

Hello!!!

- - \ No newline at end of file diff --git a/archived_packages/wings/web/site.css b/archived_packages/wings/web/site.css deleted file mode 100644 index c2140b8b..00000000 --- a/archived_packages/wings/web/site.css +++ /dev/null @@ -1,3 +0,0 @@ -h1 { - color: blue; -} \ No newline at end of file diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index dc3aabb1..1ad1bec3 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.1 + +* Fixed linter warnings + ## 7.0.0 * Require Dart >= 2.17 diff --git a/packages/auth/lib/src/middleware/require_auth.dart b/packages/auth/lib/src/middleware/require_auth.dart index f65a1a4b..26fcd4e6 100644 --- a/packages/auth/lib/src/middleware/require_auth.dart +++ b/packages/auth/lib/src/middleware/require_auth.dart @@ -25,7 +25,7 @@ RequestHandler forceBasicAuth({String? realm}) { RequestHandler requireAuthentication() { return (RequestContext req, ResponseContext res, {bool throwError = true}) async { - bool _reject(ResponseContext res) { + bool reject(ResponseContext res) { if (throwError) { res.statusCode = 403; throw AngelHttpException.forbidden(); @@ -42,10 +42,10 @@ RequestHandler requireAuthentication() { await reqContainer.makeAsync(); return true; } else { - return _reject(res); + return reject(res); } } else { - return _reject(res); + return reject(res); } }; } diff --git a/packages/auth/pubspec.yaml b/packages/auth/pubspec.yaml index d91ecd50..605024a3 100644 --- a/packages/auth/pubspec.yaml +++ b/packages/auth/pubspec.yaml @@ -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: 7.0.0 +version: 7.0.1 homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/auth environment: diff --git a/packages/auth_oauth2/CHANGELOG.md b/packages/auth_oauth2/CHANGELOG.md index ef294418..9f1cafdb 100644 --- a/packages/auth_oauth2/CHANGELOG.md +++ b/packages/auth_oauth2/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.1 + +* Updated example + ## 7.0.0 * Require Dart >= 2.17 diff --git a/packages/auth_oauth2/example/main.dart b/packages/auth_oauth2/example/main.dart index 8e6f5f4a..c2071e79 100644 --- a/packages/auth_oauth2/example/main.dart +++ b/packages/auth_oauth2/example/main.dart @@ -113,12 +113,9 @@ void main() async { } class User extends Model { - @override - String? id; - int? githubId; - User({this.id, this.githubId}); + User({super.id, this.githubId}); static User parse(Map map) => User(id: map['id'] as String?, githubId: map['github_id'] as int?); diff --git a/packages/auth_oauth2/pubspec.yaml b/packages/auth_oauth2/pubspec.yaml index 7ba2c8c6..99d05ed8 100644 --- a/packages/auth_oauth2/pubspec.yaml +++ b/packages/auth_oauth2/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_auth_oauth2 -version: 7.0.0 +version: 7.0.1 description: Angel3 library for authenticating users with external identity providers via OAuth2. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/auth_oauth2 diff --git a/packages/jael/jael_web/CHANGELOG.md b/packages/jael/jael_web/CHANGELOG.md new file mode 100644 index 00000000..344317b1 --- /dev/null +++ b/packages/jael/jael_web/CHANGELOG.md @@ -0,0 +1,38 @@ +# Change Log + +## 7.1.0 + +* Upgraded to `analyzer` 5.x.x +* Fixed deprecation + +## 7.0.0 + +* Require Dart >= 2.17 + +## 6.0.1 + +* Skipped release + +## 6.0.0 + +* Skipped release + +## 5.0.0 + +* Skipped release + +## 4.0.0 + +* Skipped release + +## 3.0.0 + +* Skipped release + +## 2.0.0 + +* Skipped release + +## 1.0.0 + +* Skipped release diff --git a/packages/jael/jael_web/lib/src/builder/util.dart b/packages/jael/jael_web/lib/src/builder/util.dart index 163feb01..31f2d66a 100644 --- a/packages/jael/jael_web/lib/src/builder/util.dart +++ b/packages/jael/jael_web/lib/src/builder/util.dart @@ -7,7 +7,7 @@ import 'package:analyzer/dart/element/type.dart'; import 'package:build/build.dart'; import 'package:code_builder/code_builder.dart'; import 'package:file/file.dart'; -import 'package:path/src/context.dart'; +import 'package:path/path.dart'; /// Converts a [DartType] to a [TypeReference]. TypeReference convertTypeReference(DartType? t) { @@ -21,7 +21,7 @@ TypeReference convertTypeReference(DartType? t) { } bool isRequiredParameter(ParameterElement e) { - return e.isNotOptional; + return e.isRequired; } bool isOptionalParameter(ParameterElement e) { @@ -233,19 +233,6 @@ class BuildSystemFile extends File { throw UnimplementedError(); } -/* - @override - Future> readAsBytes() { - var assetId = AssetId(package, path); - return reader.readAsBytes(assetId); - } - - @override - List readAsBytesSync() => throw _unsupported(); - @override - Future> readAsLines({Encoding encoding = utf8}) => - throw _unsupported(); -*/ @override List readAsLinesSync({Encoding encoding = utf8}) => throw _unsupported(); diff --git a/packages/jael/jael_web/pubspec.yaml b/packages/jael/jael_web/pubspec.yaml index 80b0a88c..85dedbe0 100644 --- a/packages/jael/jael_web/pubspec.yaml +++ b/packages/jael/jael_web/pubspec.yaml @@ -1,13 +1,16 @@ name: jael3_web -version: 7.0.0 +version: 7.1.0 description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR. publish_to: none environment: sdk: '>=2.17.0 <3.0.0' dependencies: + analyzer: ^5.0.0 build: ^2.0.2 build_config: ^1.0.0 code_builder: ^4.0.0 + file: ^6.1.4 + path: ^1.8.2 jael3: ^7.0.0 jael3_preprocessor: ^7.0.0 source_gen: ^1.0.2 diff --git a/packages/orm/angel_orm_generator/CHANGELOG.md b/packages/orm/angel_orm_generator/CHANGELOG.md index f661f30b..701bba6d 100644 --- a/packages/orm/angel_orm_generator/CHANGELOG.md +++ b/packages/orm/angel_orm_generator/CHANGELOG.md @@ -1,12 +1,18 @@ # Change Log +## 7.1.0 + +* [Breaking] Require Dart >= 2.18 +* Upgraded to `analyzer` 5.x.x +* Replaced deprecated `element2` with `element` + ## 7.0.2 * Fixed deprecated `assignVar` and `assignConst` ## 7.0.1 -* Fixed issue #82: Fixed issue #82: Removed casting for numeric fields +* Fixed issue #82: Removed casting for numeric fields ## 7.0.0 diff --git a/packages/orm/angel_orm_generator/lib/src/migration_generator.dart b/packages/orm/angel_orm_generator/lib/src/migration_generator.dart index 2f40e657..48711489 100644 --- a/packages/orm/angel_orm_generator/lib/src/migration_generator.dart +++ b/packages/orm/angel_orm_generator/lib/src/migration_generator.dart @@ -226,7 +226,7 @@ class MigrationGenerator extends GeneratorForAnnotation { defaultExpr = refer('RawSql').constInstance([literalString(value)]); } else if (type is InterfaceType && - type.element2 is EnumElement) { + type.element is EnumElement) { // Default to enum index. try { var index = diff --git a/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart b/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart index e28eb03a..34f79482 100644 --- a/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart +++ b/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart @@ -74,7 +74,7 @@ Future buildOrmContext( .firstAnnotationOf(clazz)) != null) { if (clazz.supertype != null) { - clazz = clazz.supertype!.element2; + clazz = clazz.supertype!.element; } } @@ -172,7 +172,7 @@ Future buildOrmContext( } var modelType = firstModelAncestor(refType) ?? refType; - var modelTypeElement = modelType.element2; + var modelTypeElement = modelType.element; if (modelTypeElement != null) { foreign = await buildOrmContext( @@ -188,7 +188,7 @@ Future buildOrmContext( if (through != null && through is InterfaceType) { throughContext = await buildOrmContext( cache, - through.element2, + through.element, ConstantReader(const TypeChecker.fromRuntime(Serializable) .firstAnnotationOf(modelTypeElement)), buildStep, @@ -253,9 +253,8 @@ Future buildOrmContext( // Unfortunately, the analyzer library provides little to nothing // in the way of reading enums from source, so here's a hack. var joinTypeType = (joinTypeRdr.type as InterfaceType); - var enumFields = joinTypeType.element2.fields - .where((f) => f.isEnumConstant) - .toList(); + var enumFields = + joinTypeType.element.fields.where((f) => f.isEnumConstant).toList(); for (var i = 0; i < enumFields.length; i++) { if (enumFields[i].computeConstantValue() == joinTypeRdr) { @@ -295,7 +294,7 @@ Future buildOrmContext( if (foreign != null) { if (isSpecialId(foreign, foreignField)) { // Use integer - type = field.type.element2?.library?.typeProvider.intType + type = field.type.element?.library?.typeProvider.intType as DartType; //type = field.type.element?.context.typeProvider.intType; @@ -364,7 +363,7 @@ ColumnType inferColumnType(DartType type) { if (const TypeChecker.fromRuntime(List).isAssignableFromType(type)) { return ColumnType.jsonb; } - if (type is InterfaceType && type.element2 is EnumElement) { + if (type is InterfaceType && type.element is EnumElement) { return ColumnType.int; } diff --git a/packages/orm/angel_orm_generator/lib/src/orm_generator.dart b/packages/orm/angel_orm_generator/lib/src/orm_generator.dart index c61e25c2..69e607e9 100644 --- a/packages/orm/angel_orm_generator/lib/src/orm_generator.dart +++ b/packages/orm/angel_orm_generator/lib/src/orm_generator.dart @@ -249,7 +249,7 @@ class OrmGenerator extends GeneratorForAnnotation { var args = {}; for (var field in ctx.effectiveFields) { var fType = field.type; - Reference type = convertTypeReference(field.type); + Reference type = convertTypeReference(fType); if (isSpecialId(ctx, field)) { type = refer('int'); } @@ -271,14 +271,21 @@ class OrmGenerator extends GeneratorForAnnotation { // .call([expr.property('toString').call([])]); expr = refer('mapToDouble').call([expr]); } else if (fType is InterfaceType && - fType.element2 is EnumElement) { + fType.element is EnumElement) { + /* + * fields.contains('type') ? row[3] == null ? null : + * EnumType.values[(row[3] as int)] : null, + */ var isNull = expr.equalTo(literalNull); + + Reference enumType = + convertTypeReference(fType, ignoreNullabilityCheck: true); expr = isNull.conditional(literalNull, - type.property('values').index(expr.asA(refer('int')))); + enumType.property('values').index(expr.asA(refer('int')))); } else if (fType.isDartCoreBool) { // Generated Code: mapToBool(row[i]) expr = refer('mapToBool').call([expr]); - } else if (fType.element2?.displayName == 'DateTime') { + } else if (fType.element?.displayName == 'DateTime') { // Generated Code: mapToDateTime(row[i]) if (fType.nullabilitySuffix == NullabilitySuffix.question) { expr = refer('mapToNullableDateTime').call([expr]); @@ -300,7 +307,7 @@ class OrmGenerator extends GeneratorForAnnotation { defaultRef = CodeExpression(Code('0.0')); } else if (fType.isDartCoreInt || fType.isDartCoreNum) { defaultRef = CodeExpression(Code('0')); - } else if (fType.element2?.displayName == 'DateTime') { + } else if (fType.element?.displayName == 'DateTime') { defaultRef = CodeExpression( Code('DateTime.parse("1970-01-01 00:00:00")')); } else if (fType.isDartCoreList) { @@ -748,7 +755,7 @@ class OrmGenerator extends GeneratorForAnnotation { builderType = TypeReference((b) => b ..symbol = 'NumericSqlExpressionBuilder' ..types.add(refer(typeName))); - } else if (type is InterfaceType && type.element2 is EnumElement) { + } else if (type is InterfaceType && type.element is EnumElement) { builderType = TypeReference((b) => b ..symbol = 'EnumSqlExpressionBuilder' ..types.add(convertTypeReference(type))); @@ -884,9 +891,9 @@ class OrmGenerator extends GeneratorForAnnotation { clazz.methods.add(Method((b) { var value = refer('values').index(literalString(name!)); - if (fType is InterfaceType && fType.element2 is EnumElement) { + if (fType is InterfaceType && fType.element is EnumElement) { var asInt = value.asA(refer('int')); - var t = convertTypeReference(fType); + var t = convertTypeReference(fType, ignoreNullabilityCheck: true); value = t.property('values').index(asInt); } else if (const TypeChecker.fromRuntime(List) .isAssignableFromType(fType)) { @@ -918,7 +925,7 @@ class OrmGenerator extends GeneratorForAnnotation { clazz.methods.add(Method((b) { Expression value = refer('value'); - if (fType is InterfaceType && fType.element2 is EnumElement) { + if (fType is InterfaceType && fType.element is EnumElement) { value = CodeExpression(Code('value?.index')); } else if (const TypeChecker.fromRuntime(List) .isAssignableFromType(fType)) { diff --git a/packages/orm/angel_orm_generator/pubspec.yaml b/packages/orm/angel_orm_generator/pubspec.yaml index f695df0c..39ddfa7a 100644 --- a/packages/orm/angel_orm_generator/pubspec.yaml +++ b/packages/orm/angel_orm_generator/pubspec.yaml @@ -1,16 +1,16 @@ name: angel3_orm_generator -version: 7.0.2 +version: 7.1.0 description: Code generators for Angel3 ORM. Generates query builder classes. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_generator environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: angel3_model: ^7.0.0 angel3_serialize: ^7.0.0 angel3_orm: ^7.0.0 angel3_serialize_generator: ^7.0.0 - analyzer: ^4.0.0 + analyzer: ^5.0.0 inflection3: ^0.5.3+1 build: ^2.0.1 build_config: ^1.0.0 @@ -30,7 +30,7 @@ dev_dependencies: postgres: ^2.4.0 test: ^1.21.0 lints: ^2.0.0 -# dependency_overrides: +dependency_overrides: # angel3_container: # path: ../../container/angel_container # angel3_framework: @@ -43,10 +43,10 @@ dev_dependencies: # path: ../../route # angel3_mock_request: # path: ../../mock_request -# angel3_serialize: -# path: ../../serialize/angel_serialize -# angel3_serialize_generator: -# path: ../../serialize/angel_serialize_generator +# angel3_serialize: +# path: ../../serialize/angel_serialize + angel3_serialize_generator: + path: ../../serialize/angel_serialize_generator # angel3_orm: # path: ../angel_orm # angel3_migration: diff --git a/packages/orm/angel_orm_test/CHANGELOG.md b/packages/orm/angel_orm_test/CHANGELOG.md index bbc9f3fc..b74e9fd7 100644 --- a/packages/orm/angel_orm_test/CHANGELOG.md +++ b/packages/orm/angel_orm_test/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.1.0 + +* [Breaking] Require Dart >= 2.18 + ## 7.0.2 * Fixed null safety warnings diff --git a/packages/orm/angel_orm_test/lib/src/models/has_car.dart b/packages/orm/angel_orm_test/lib/src/models/has_car.dart index f9b1af00..7fef8b81 100644 --- a/packages/orm/angel_orm_test/lib/src/models/has_car.dart +++ b/packages/orm/angel_orm_test/lib/src/models/has_car.dart @@ -3,7 +3,6 @@ import 'package:angel3_orm/angel3_orm.dart'; import 'package:angel3_serialize/angel3_serialize.dart'; import 'package:optional/optional.dart'; -// import 'car.dart'; part 'has_car.g.dart'; // Map _carToMap(Car car) => car.toJson(); diff --git a/packages/orm/angel_orm_test/pubspec.yaml b/packages/orm/angel_orm_test/pubspec.yaml index df6730f8..949ca0e3 100644 --- a/packages/orm/angel_orm_test/pubspec.yaml +++ b/packages/orm/angel_orm_test/pubspec.yaml @@ -1,10 +1,10 @@ name: angel3_orm_test -version: 7.0.2 +version: 7.1.0 description: Common tests for Angel3 ORM. Reference implmentation of the generated ORM files. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_test environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: angel3_migration: ^7.0.0 angel3_model: ^7.0.0 @@ -19,7 +19,7 @@ dev_dependencies: angel3_framework: ^7.0.0 build_runner: ^2.0.1 lints: ^2.0.0 -#dependency_overrides: +dependency_overrides: # angel3_container: # path: ../../container/angel_container # angel3_framework: @@ -34,11 +34,11 @@ dev_dependencies: # path: ../../mock_request # angel3_serialize: # path: ../../serialize/angel_serialize -# angel3_serialize_generator: -# path: ../../serialize/angel_serialize_generator + angel3_serialize_generator: + path: ../../serialize/angel_serialize_generator # angel3_orm: # path: ../angel_orm # angel3_migration: # path: ../angel_migration -# angel3_orm_generator: -# path: ../angel_orm_generator + angel3_orm_generator: + path: ../angel_orm_generator diff --git a/packages/serialize/angel_serialize_generator/CHANGELOG.md b/packages/serialize/angel_serialize_generator/CHANGELOG.md index a59ea888..1bbaa7c0 100644 --- a/packages/serialize/angel_serialize_generator/CHANGELOG.md +++ b/packages/serialize/angel_serialize_generator/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 7.1.0 + +* [Breaking] Require Dart >= 2.18 +* Upgraded to `analyzer` 5.x.x +* Replaced deprecated `element2` with `element` + ## 7.0.0 * Require Dart >= 2.17 diff --git a/packages/serialize/angel_serialize_generator/lib/angel3_serialize_generator.dart b/packages/serialize/angel_serialize_generator/lib/angel3_serialize_generator.dart index d42c6287..d9914a5b 100644 --- a/packages/serialize/angel_serialize_generator/lib/angel3_serialize_generator.dart +++ b/packages/serialize/angel_serialize_generator/lib/angel3_serialize_generator.dart @@ -38,13 +38,18 @@ Builder typescriptDefinitionBuilder(_) { } /// Converts a [DartType] to a [TypeReference]. -TypeReference convertTypeReference(DartType t, {bool forceNullable = false}) { +TypeReference convertTypeReference(DartType t, + {bool forceNullable = false, bool ignoreNullabilityCheck = false}) { return TypeReference((b) { - b.symbol = t.element2?.displayName; + b.symbol = t.element?.displayName; // Generate nullable type - if (t.nullabilitySuffix == NullabilitySuffix.question || forceNullable) { - b.isNullable = true; + if (ignoreNullabilityCheck) { + b.isNullable = false; + } else { + if (t.nullabilitySuffix == NullabilitySuffix.question || forceNullable) { + b.isNullable = true; + } } if (t is InterfaceType) { @@ -112,21 +117,21 @@ String? dartObjectToString(DartObject v) { .accept(DartEmitter(useNullSafetySyntax: true)) .toString(); } - if (type is InterfaceType && type.element2 is EnumElement) { + if (type is InterfaceType && type.element is EnumElement) { // Find the index of the enum, then find the member. - for (var field in type.element2.fields) { + for (var field in type.element.fields) { if (field.isEnumConstant && field.isStatic) { - var value = type.element2.getField(field.name)!.computeConstantValue(); + var value = type.element.getField(field.name)!.computeConstantValue(); if (v is Enum && value is Enum) { var v2 = v as Enum; var value2 = value as Enum; if (value2.name == v2.name) { - return '${type.element2.displayName}.${field.name}'; + return '${type.element.displayName}.${field.name}'; } } else { if (value == v) { - return '${type.element2.displayName}.${field.name}'; + return '${type.element.displayName}.${field.name}'; } } } @@ -140,11 +145,11 @@ String? dartObjectToString(DartObject v) { bool isModelClass(DartType? t) { if (t == null) return false; - if (serializableTypeChecker.hasAnnotationOf(t.element2!)) { + if (serializableTypeChecker.hasAnnotationOf(t.element!)) { return true; } - if (generatedSerializableTypeChecker.hasAnnotationOf(t.element2!)) { + if (generatedSerializableTypeChecker.hasAnnotationOf(t.element!)) { return true; } @@ -177,7 +182,7 @@ bool isListOrMapType(DartType t) { bool isEnumType(DartType t) { if (t is InterfaceType) { - return t.element2 is Enum; + return t.element is Enum; } return false; @@ -204,13 +209,13 @@ bool isAssignableToModel(DartType type) => String? typeToString(DartType type) { if (type is InterfaceType) { if (type.typeArguments.isEmpty) { - return type.element2.displayName; + return type.element.displayName; } - var name = type.element2.displayName; + var name = type.element.displayName; return '$name<${type.typeArguments.map(typeToString).join(', ')}>'; } else { - return type.element2?.displayName; + return type.element?.displayName; } } diff --git a/packages/serialize/angel_serialize_generator/lib/build_context.dart b/packages/serialize/angel_serialize_generator/lib/build_context.dart index acbd0444..91436cc9 100644 --- a/packages/serialize/angel_serialize_generator/lib/build_context.dart +++ b/packages/serialize/angel_serialize_generator/lib/build_context.dart @@ -62,7 +62,7 @@ Future buildContext( // Crawl for classes from parent classes. void crawlClass(InterfaceType? t) { while (t != null) { - fields.insertAll(0, t.element2.fields); + fields.insertAll(0, t.element.fields); t.interfaces.forEach(crawlClass); t = t.superclass; } diff --git a/packages/serialize/angel_serialize_generator/lib/model.dart b/packages/serialize/angel_serialize_generator/lib/model.dart index 11096f72..3285cb5e 100644 --- a/packages/serialize/angel_serialize_generator/lib/model.dart +++ b/packages/serialize/angel_serialize_generator/lib/model.dart @@ -254,7 +254,7 @@ class JsonModelGenerator extends GeneratorForAnnotation { if (const TypeChecker.fromRuntime(List).isAssignableFromType(type)) { if (type.typeArguments.length == 1) { var eq = generateEquality(type.typeArguments[0]); - return 'ListEquality<${type.typeArguments[0].element2!.name}>($eq)'; + return 'ListEquality<${type.typeArguments[0].element!.name}>($eq)'; } else { return 'ListEquality()'; } @@ -263,20 +263,20 @@ class JsonModelGenerator extends GeneratorForAnnotation { if (type.typeArguments.length == 2) { var keq = generateEquality(type.typeArguments[0]), veq = generateEquality(type.typeArguments[1]); - return 'MapEquality<${type.typeArguments[0].element2!.name}, ${type.typeArguments[1].element2!.name}>(keys: $keq, values: $veq)'; + return 'MapEquality<${type.typeArguments[0].element!.name}, ${type.typeArguments[1].element!.name}>(keys: $keq, values: $veq)'; } else { return 'MapEquality()'; } } - return nullable ? null : 'DefaultEquality<${type.element2.name}>()'; + return nullable ? null : 'DefaultEquality<${type.element.name}>()'; } else { return 'DefaultEquality()'; } } static String Function(String, String) generateComparator(DartType type) { - if (type is! InterfaceType || type.element2.displayName == 'dynamic') { + if (type is! InterfaceType || type.element.displayName == 'dynamic') { return (a, b) => '$a == $b'; } var eq = generateEquality(type, true); diff --git a/packages/serialize/angel_serialize_generator/lib/serialize.dart b/packages/serialize/angel_serialize_generator/lib/serialize.dart index 4c5c26ce..7254a1e6 100644 --- a/packages/serialize/angel_serialize_generator/lib/serialize.dart +++ b/packages/serialize/angel_serialize_generator/lib/serialize.dart @@ -214,7 +214,7 @@ class ${pascal}Decoder extends Converter { return (map as Map?)?..[key] = ${serializerToMap(rc, 'model.${field.name}[key]')}; })'''; - } else if (type.element2 is Enum) { + } else if (type.element is Enum) { var convert = (field.type.nullabilitySuffix == NullabilitySuffix.question) ? '!' @@ -390,7 +390,7 @@ class ${pascal}Decoder extends Converter { })) : $defaultValue '''; - } else if (type.element2 is Enum) { + } else if (type.element is Enum) { deserializedRepresentation = ''' map['$alias'] is ${type.getDisplayString(withNullability: true)} ? (map['$alias'] as ${type.getDisplayString(withNullability: true)}) ?? $defaultValue diff --git a/packages/serialize/angel_serialize_generator/lib/typescript.dart b/packages/serialize/angel_serialize_generator/lib/typescript.dart index 78187784..45bbf304 100644 --- a/packages/serialize/angel_serialize_generator/lib/typescript.dart +++ b/packages/serialize/angel_serialize_generator/lib/typescript.dart @@ -77,15 +77,15 @@ class TypeScriptDefinitionBuilder implements Builder { } } else if (isModelClass(type)) { var sourcePath = buildStep.inputId.uri.toString(); - var targetPath = type.element2.source.uri.toString(); + var targetPath = type.element.source.uri.toString(); if (!p.equals(sourcePath, targetPath)) { var relative = p.relative(targetPath, from: sourcePath); String? ref; - if (type.element2.source.uri.scheme == 'asset') { + if (type.element.source.uri.scheme == 'asset') { var id = - AssetId.resolve(Uri.parse(type.element2.source.uri.toString())); + AssetId.resolve(Uri.parse(type.element.source.uri.toString())); if (id.package != buildStep.inputId.package) { ref = '/// '; } @@ -105,9 +105,9 @@ class TypeScriptDefinitionBuilder implements Builder { } var ctx = await buildContext( - type.element2, + type.element, ConstantReader( - serializableTypeChecker.firstAnnotationOf(type.element2)), + serializableTypeChecker.firstAnnotationOf(type.element)), buildStep, buildStep.resolver, autoSnakeCaseNames, diff --git a/packages/serialize/angel_serialize_generator/pubspec.yaml b/packages/serialize/angel_serialize_generator/pubspec.yaml index eab35bdf..a1305c6e 100644 --- a/packages/serialize/angel_serialize_generator/pubspec.yaml +++ b/packages/serialize/angel_serialize_generator/pubspec.yaml @@ -1,12 +1,12 @@ name: angel3_serialize_generator -version: 7.0.0 +version: 7.1.0 description: Angel3 model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/serialize/angel_serialize_generator environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: - analyzer: ^4.1.0 + analyzer: ^5.0.0 angel3_model: ^7.0.0 angel3_serialize: ^7.0.0 belatuk_code_buffer: ^4.0.0 diff --git a/packages/serialize/angel_serialize_generator/test/models/book.g.dart b/packages/serialize/angel_serialize_generator/test/models/book.g.dart index bd2f4488..92623179 100644 --- a/packages/serialize/angel_serialize_generator/test/models/book.g.dart +++ b/packages/serialize/angel_serialize_generator/test/models/book.g.dart @@ -620,8 +620,8 @@ class LibrarySerializer extends Codec { 'created_at': model.createdAt?.toIso8601String(), 'updated_at': model.updatedAt?.toIso8601String(), 'collection': model.collection.keys.fold({}, (map, key) { - return (map as Map?) - ?..[key] = BookSerializer.toMap(model.collection[key]); + return (map as Map) + ..[key] = BookSerializer.toMap(model.collection[key]); }) }; } diff --git a/packages/static/lib/src/virtual_directory.dart b/packages/static/lib/src/virtual_directory.dart index 1f96276c..e282ae01 100644 --- a/packages/static/lib/src/virtual_directory.dart +++ b/packages/static/lib/src/virtual_directory.dart @@ -226,7 +226,6 @@ class VirtualDirectory { type = '[Link]'; stub = p.basename(entity.path); } else { - //TODO: Handle unknown type _log.severe('Unknown file entity. Not a file, directory or link.'); type = '[]'; stub = ''; diff --git a/packages/sync/example/main.dart b/packages/sync/example/main.dart index f11908ff..341a8e0d 100644 --- a/packages/sync/example/main.dart +++ b/packages/sync/example/main.dart @@ -34,7 +34,6 @@ void main() { // propagate to app2. var ws = req.container!.make(); - // TODO: body retuns void //var body = await req.parseBody(); var body = {}; await ws.batchEvent(WebSocketEvent( diff --git a/packages/user_agent/angel_user_agent/example/example.dart b/packages/user_agent/angel_user_agent/example/example.dart index 786cd448..efadec2c 100644 --- a/packages/user_agent/angel_user_agent/example/example.dart +++ b/packages/user_agent/angel_user_agent/example/example.dart @@ -1,8 +1,8 @@ -import 'dart:io'; +//import 'dart:io'; import 'package:angel3_framework/angel3_framework.dart'; import 'package:angel3_framework/http.dart'; -import 'package:angel3_user_agent/angel3_user_agent.dart'; -import 'package:user_agent_analyzer/user_agent_analyzer.dart'; +//import 'package:angel3_user_agent/angel3_user_agent.dart'; +//import 'package:user_agent_analyzer/user_agent_analyzer.dart'; void main() async { var app = Angel(); diff --git a/packages/validate/CHANGELOG.md b/packages/validate/CHANGELOG.md index 738e1c56..c04e990f 100644 --- a/packages/validate/CHANGELOG.md +++ b/packages/validate/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.1 + +* Fixed linter warnings + ## 7.0.0 * Require Dart >= 2.17 diff --git a/packages/validate/lib/src/validator.dart b/packages/validate/lib/src/validator.dart index 9548c41f..e52ff0da 100644 --- a/packages/validate/lib/src/validator.dart +++ b/packages/validate/lib/src/validator.dart @@ -83,15 +83,15 @@ class Validator extends Matcher { schema[keys] is Iterable ? schema[keys] : [schema[keys]]; var iterable = []; - void _addTo(x) { + void addTo(x) { if (x is Iterable) { - x.forEach(_addTo); + x.forEach(addTo); } else { iterable.add(x); } } - tmpIterable.forEach(_addTo); + tmpIterable.forEach(addTo); for (var rule in iterable) { if (rule is Matcher) { diff --git a/packages/validate/pubspec.yaml b/packages/validate/pubspec.yaml index 7a780f8a..3ebe34b4 100644 --- a/packages/validate/pubspec.yaml +++ b/packages/validate/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_validate description: Cross-platform request body validation library based on `matcher`. -version: 7.0.0 +version: 7.0.1 homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/validate environment: