google / streamy-dart Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
r37858 added new optimizations to dart:convert JSON codec. Streamy should take advantage of that.
when in run app to generate lib not happend anything only show again and again the paremeters message but not error, not messages and of course not generate lib anything. I do not what solve problemn.
casa bin # ./dart /home/albertog/streamy-dart/bin/apigen.dart --client-file-name=aa.dart --discovery-file=urlshortener.json --output-dir=url
-c, --client-file-name Prefix for the .dart files generated.
-d, --discovery-file Path to the discovery file.
-o, --output-dir Directory for the generated client library package.
-a, --addendum-file Path to addendum to the discovery file.
-t, --templates-dir Directory containing code templates.
(defaults to "templates")
-v, --package-version Version to be specified in the generated pubspec.yaml
(defaults to "0.0.0")
--local-streamy-location Path to a local Streamy package. If specified the local version will be used instead of pub version.
Hi, README.md file says that Google Discovery format is suitable for "own APIs hosted on own servers". Haven't found any example. Please, could you provide a reference to any relevant example? What are requirements to server-side implementation to support the same set of features listed in the README.md? Thanks!
There's just too many .then
s and variable scope issues.
Generated classes should have "kind" field populated during object construction.
Ex:
var test = new Foo();
expect(test.kind, "abc#foo");
Could we have a utility function that listens to all changes deep within an entity (to be used with caution, of course). Right now, we can only watch the top level using item.changes.listen. If I had these example classes:
class Item1 {
String attribute1;
Object2 attribute2;
}
class Item2 {
String attributeA;
Item2 attributeB;
List attributeC;
}
and I had an object:
Item1 objectX = new Item1();
If I wanted to watch for all changes in 'objectX', I could not just use objectX.changes.listen, because it would only observe changes in objectX.attribute1 and any additions or removals from objectX.attributeC. It would not observe changes to attributeB or any changes to existing Item2s in attributeC.
Please add a utility for listening to deep changes in an entity. Thanks.
I've just used Streamy to generate the code to talk to the Google Calendar API.
https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest
The API is called Calendar, and the schema object is also called Calendar. So, I end up with generated code including:
class Calendar extends base.EntityWrapper {
....
}
class Calendar extends base.Root {
...
}
As you can imagine, this causes unhappiness when the Streamy API layer is used.
With GlobalView.register the value of generated addGlobal functions and *GlobalFn typedefs is dubious, but they are guaranteed to waste valuable code size budget. Let's remove them.
This is an API breaking proposal, so let's postpone it till after 0.2 is released.
Sometimes the path parameters for a request are to be sourced from the values stored in the payload, not the request itself. Streamy needs to handle this.
As of now (9/9/14), there are 52 problems, 295 warnings, and 39 hints from Dart analyzer in a clean external copy of the Streamy master branch. Many are due to using dynamics without casting.
This should be cleaned up to make it easier / less scary for more contributors. I'll contribute, but I could use your help ๐
It would be nice if the caller were able to specify a list of return codes (504, etc.) that would trigger an automatic retry. This way, if there's a temporary resource issue, it won't force the user of the app to reload the entire page to work around it, or require custom code all over the app to do it everywhere Streamy is called.
Error details:
Bad state: Cannot add new events after calling close
STACKTRACE:
#0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:217)
#1 _StreamTrace.record (package:streamy/lib/runtime/tracing.dart:50:20)
#2 Multiplexer._sendRpc. (package:streamy/lib/runtime/multiplexer.dart:135:23)
#3 Multiplexer._removeActive (package:streamy/lib/runtime/multiplexer.dart:239:40)
#4 Multiplexer._newActiveStream. (package:streamy/lib/runtime/multiplexer.dart:83:51)
#5 _Future._propagateToListeners. (dart:async/future_impl.dart:485)
#6 _rootRun (dart:async/zone.dart:720)
#7 _ZoneDelegate.run (dart:async/zone.dart:438)
#8 _onRun. (package:angular/lib/core/zone.dart:62:63)
#9 NgZone._onRunBase (package:angular/lib/core/zone.dart:49:16)
#10 _onRun (package:angular/lib/core/zone.dart:62:22)
#11 _ZoneDelegate.run (dart:async/zone.dart:438)
#12 _CustomizedZone.run (dart:async/zone.dart:657)
#13 _Future._propagateToListeners (dart:async/future_impl.dart:449)
#14 _Future._complete (dart:async/future_impl.dart:302)
#15 _Future._asyncComplete. (dart:async/future_impl.dart:358)
#16 _rootRun (dart:async/zone.dart:720)
#17 _ZoneDelegate.run (dart:async/zone.dart:438)
#18 _onScheduleMicrotask. (package:angular/lib/core/zone.dart:70:39)
#19 _rootRun (dart:async/zone.dart:725)
#20 _ZoneDelegate.run (dart:async/zone.dart:438)
#21 NgZone._finishTurn (package:angular/lib/core/zone.dart:95:23)
#22 NgZone._onRunBase (package:angular/lib/core/zone.dart:57:20)
#23 _onRun (package:angular/lib/core/zone.dart:62:22)
#24 _ZoneDelegate.run (dart:async/zone.dart:438)
Per alk@'s API proposal for transactions, Streamy needs to support batching and sending multipart requests together in a single transaction.
I have some ideas for how this might work and will be implementing them in Streamy so we can hit the ground running with transactional support.
It would be nice to define how to generate the API from pubspec.yaml
, either from a local .json discovery file or from a URL:
transformers:
streamy:
discovery_services: [
"prefetched_discovery_files/auth_service.json",
"https://www.googleapis.com/discovery/v1/apis/urlshortener/v1/rest"
]
Writing & bundling a transformer is very simple, happy to give it a go if that's a feature that makes sense to you guys :-)
We currently have a 50%/50% mix, which doesn't make sense
Support options:
--output-dir
--package-name
--package-version
--config
streamy-dart # /home/albertog/dart/dart-sdk/bin/dart bin/apigen.dart --discover_file=urlshortener.json --client_file=urlshortener.dart --library_name=urlshortener
Unable to open file: /home/albertog/Documents/streamy-dart/bin/packages/args/args.dart'file:///home/albertog/Documents/streamy-dart/bin/apigen.dart': error: line 2 pos 1: library handler failed
import 'package:args/args.dart';
^
windows7 32bits
Should not have to do new XyzEntity().apiType to access apiType. It is reasonable to have two getters, one which is a static and the other which is non-static. Non-static can refer to the static getter.
Add support for constructing a frozen entity or marking an entity as frozen.
While you can currently let ComparableMap extend HashMap, it's likely to not be possible in the future.
I recommend delegating to an internal Map instead of extending HashMap. That will also make it work for any Map, not just HashMap.
@alxhub -- we discussed this briefly in person
(api.foo.list()
..cacheable = false).send();
And possibly to exclude certain request types from caching completely.
Streamy generates a request class for each API method by capitalizing method name and appending "Request" and using that as the request class' name. Unfortunately this leads to name conflicts if there is a schema object with the same name.
Streamy should split resources, methods and entities into separate libraries to avoid name conflicts.
The idea is to provide a way to say "I want all entities of type 'Foo' to have field 'bar', which is a computation on ..."
Sample usage:
// Makes field named 'bar' available to all entities of type 'Foo'
// and its value is a computation on fields 'a' and 'b'. This would
// be done during the initialization of the app.
Foo.addCommonLocalField('bar', (Foo entity) => entity.a + entity.b);
// In any other part of the code a developer could do this
Foo e = new Foo() // note that we're not setting 'bar' explicitly
..a = 1
..b = 3;
expect(e.local['bar'], 4); // and yet it is available
A 204 response from a HTTP DELETE request is not handled correctly. The response body of a 204 is empty, but Streamy attempts to parse it, throwing a FormatException in the JsonParser.
(logging this request on behalf of @irfantusneem from an offline conversation)
In Streamy entities are nested within entities. Currently, you can use operator[] with a deep key, e.g. e["a.b"] fetches e.a.b in a null-safe manner. However, there's no way to check if key "a.b" exists. We need a "contains" method that complements the behavior of operator[].
I'm helping w/ the dart-gde impl of the same library.
@financecoding and I love the mustache template model.
Would love to collaborate
https://github.com/dart-gde/discovery_api_dart_client_generator/
An attempt at doing so results in this:
Unhandled exception:
The null object does not have a getter 'iterator'.
NoSuchMethodError : method not found: 'iterator'
Receiver: null
Arguments: []
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1 List.addAll (dart:core-patch/growable_array.dart:186)
#2 ObservableList.addAll (package:observe/src/observable_list.dart:144:17)
#3 ObservableList.ObservableList.from (package:observe/src/observable_list.dart:42:38)
Would like to override hashCode and equals for a streamy entity? It is reasonable for it to throw an exception if someone attempts to override it more than once.
Ex:
var x = new AbcRef()..id = 1;
var y = new AbcRef()..id = 1
..name = 'hi';
It should be reasonable for x == y to be true since the id is the unique identifier of the object and name is a helper/computed field.
If a non-GET request is issued between two identical GET requests and the first GET request is still in-flight, the second request should fire a new GET request and not subscribe to the first one.
When running
dart bin/apigen.dart -d urlshortener.json -o shortener
I get
Unhandled exception:
Class '_LocalClassMirror' has no instance getter 'members'.
NoSuchMethodError : method not found: 'members'
Receiver: Instance of '_LocalClassMirror'
Arguments: []
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1 _Template._getNamedProperty (package:mustache/template.dart:162:29)
#2 _Template._resolveValue (package:mustache/template.dart:132:30)
#3 _Template._renderVariable (package:mustache/template.dart:179:30)
#4 _renderNode (package:mustache/template.dart:101:20)
#5 List.forEach (dart:core-patch/growable_array.dart:240)
#6 _Template._renderSectionWithValue (package:mustache/template.dart:197:24)
#7 _Template._renderSection.<anonymous closure> (package:mustache/template.dart:206:48)
#8 List.forEach (dart:core-patch/growable_array.dart:240)
#9 _Template._renderSection (package:mustache/template.dart:206:17)
#10 _renderNode (package:mustache/template.dart:107:19)
#11 List.forEach (dart:core-patch/growable_array.dart:240)
#12 _Template._renderSectionWithValue (package:mustache/template.dart:197:24)
#13 _Template._renderSection.<anonymous closure> (package:mustache/template.dart:206:48)
#14 List.forEach (dart:core-patch/growable_array.dart:240)
#15 _Template._renderSection (package:mustache/template.dart:206:17)
#16 _renderNode (package:mustache/template.dart:107:19)
#17 List.forEach (dart:core-patch/growable_array.dart:240)
#18 _Template.render (package:mustache/template.dart:89:25)
#19 _Template.renderString (package:mustache/template.dart:80:9)
#20 _InternalTemplate.render (package:streamy/generator/emitter.dart:655:41)
#21 _Emitter.processObjectType (package:streamy/generator/emitter.dart:283:19)
#22 _Emitter.processType (package:streamy/generator/emitter.dart:242:26)
#23 _Emitter.generate.<anonymous closure> (package:streamy/generator/emitter.dart:142:18)
#24 _HashMap&_LinkedHashMapMixin.forEach (dart:collection-patch/collection_patch.dart:965)
#25 _Emitter.generate (package:streamy/generator/emitter.dart:141:36)
#26 emitCode (package:streamy/generator/emitter.dart:4:32)
#27 generateStreamyClientLibrary (package:streamy/generator_utils.dart:39:11)
#28 main (file:///usr/local/google/home/polux/projects/streamy-dart/bin/apigen.dart:17:31)
#29 _startIsolate.isolateStartHandler (dart:isolate-patch/isolate_patch.dart:214)
#30 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:115)
The README instructions are out of date w.r.t. apigen.dart's flags.
We should have a much better README, as well as automatically generated documentation based on code.
The implementation of toJson in RawEntity is flawed. Instead of serializing null properties as nulls, it simply removes them from JSON. This is wrong, because JSON is perfectly capable of expressing nulls and missing properties and Streamy already provides remove* methods to actually remove properties.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.