[cleanup] Removed unused/deprecated packages
TEST=
- no testing required, just removes unused packages.
Change-Id: I366235af88302b011c31069fde34af88c059a6d0
diff --git a/BUILD.gn b/BUILD.gn
index ca6f903..17e35c1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -11,7 +11,6 @@
"examples/test/flutter_widget_test:flutter_widget_test",
"public/dart/sledge:dart_sledge_tests",
"public/lib/app/dart:dart_app_tests",
- "public/lib/schemas/dart:dart_schema_tests",
"shell:tests",
]
}
diff --git a/README.md b/README.md
index aeed6b3..a561f9d 100644
--- a/README.md
+++ b/README.md
@@ -44,3 +44,6 @@
* topaz/public/lib/proposal: d32421a9d
* topaz/public/lib/user: 62cc03e
* topaz/lib/setui/settings: 4009b4a
+* topaz/public/lib/schemas: e5810dfa1
+* topaz/public/lib/entity: e5810dfa1
+* topaz/public/lib/component: e5810dfa1
diff --git a/packages/tests/BUILD.gn b/packages/tests/BUILD.gn
index 4703d2b..4659af1 100644
--- a/packages/tests/BUILD.gn
+++ b/packages/tests/BUILD.gn
@@ -38,7 +38,6 @@
"//topaz/public/dart/widgets:dart_widget_tests($host_toolchain)",
"//topaz/public/lib/app/dart:dart_app_tests($host_toolchain)",
"//topaz/public/lib/display/flutter:display_test($host_toolchain)",
- "//topaz/public/lib/schemas/dart:dart_schema_tests($host_toolchain)",
"//topaz/shell/mondrian_story_shell:mondrian_story_shell_tests($host_toolchain)",
]
}
diff --git a/public/lib/component/dart/BUILD.gn b/public/lib/component/dart/BUILD.gn
deleted file mode 100644
index 684183c..0000000
--- a/public/lib/component/dart/BUILD.gn
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/dart/dart_library.gni")
-
-dart_library("dart") {
- package_name = "lib.component.dart"
-
- sdk_category = "partner"
-
- sources = [
- "component.dart",
- "src/component_context_client.dart",
- "component_async.dart",
- "src/message_sender_client.dart",
- "src/message_sender_client_async.dart",
- "src/message_queue_client.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.modular",
- "//topaz/public/dart/fidl",
- "//topaz/public/dart/zircon",
- "//topaz/public/lib/app/dart",
- "//topaz/public/lib/entity/dart",
- "//zircon/public/fidl/fuchsia-mem",
- ]
-}
diff --git a/public/lib/component/dart/analysis_options.yaml b/public/lib/component/dart/analysis_options.yaml
deleted file mode 100644
index 54917c0..0000000
--- a/public/lib/component/dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2017 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-include: ../../../analysis_options.yaml
diff --git a/public/lib/component/dart/lib/component.dart b/public/lib/component/dart/lib/component.dart
deleted file mode 100644
index 4af8def..0000000
--- a/public/lib/component/dart/lib/component.dart
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/component_context_client.dart';
-export 'src/message_queue_client.dart';
-export 'src/message_sender_client.dart';
diff --git a/public/lib/component/dart/lib/component_async.dart b/public/lib/component/dart/lib/component_async.dart
deleted file mode 100644
index 3666fe7..0000000
--- a/public/lib/component/dart/lib/component_async.dart
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/component_context_client.dart';
-export 'src/message_queue_client.dart';
-export 'src/message_sender_client_async.dart';
diff --git a/public/lib/component/dart/lib/src/component_context_client.dart b/public/lib/component/dart/lib/src/component_context_client.dart
deleted file mode 100644
index 1fef677..0000000
--- a/public/lib/component/dart/lib/src/component_context_client.dart
+++ /dev/null
@@ -1,212 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_modular/fidl.dart' as fidl;
-import 'package:fidl_fuchsia_sys/fidl.dart' as fidl;
-import 'package:lib.app.dart/logging.dart';
-import 'package:lib.component.dart/component.dart';
-import 'package:lib.entity.dart/entity.dart';
-import 'package:meta/meta.dart';
-
-/// A client wrapper for [fidl.ComponentContext].
-class ComponentContextClient {
- /// The underlying [Proxy] used to send client requests to the
- /// [fidl.ComponentContextProxy] service.
- final fidl.ComponentContextProxy proxy = fidl.ComponentContextProxy();
-
- final EntityResolverClient _entityResolver = EntityResolverClient();
-
- // Keep track of agent controllers created to close the channels onTerminate
- final List<fidl.AgentControllerProxy> _agentControllers =
- <fidl.AgentControllerProxy>[];
-
- /// Constructor.
- ComponentContextClient() {
- proxy.ctrl
- ..onBind = _handleBind
- ..onClose = _handleClose
- ..onConnectionError = _handleConnectionError
- ..onUnbind = _handleUnbind;
- }
-
- /// A future that completes when the [proxy] is bound.
- Future<Null> get bound => _bind.future;
- final Completer<Null> _bind = Completer<Null>();
-
- /// See [fidl.ComponentContext#createEntityWithData].
- Future<String> createEntityWithData(List<fidl.TypeToDataEntry> typeToData) {
- Completer<String> completer = Completer<String>();
-
- // ignore: unawaited_futures
- proxy.ctrl.error.then((ProxyError err) {
- if (!completer.isCompleted) {
- completer.completeError(err);
- }
- });
-
- void onSuccess(String value) {
- if (!completer.isCompleted) {
- if (value != null) {
- completer.complete(value);
- } else {
- completer.completeError(Exception('entity reference is null'));
- }
- }
- }
-
- try {
- proxy.createEntityWithData(typeToData, onSuccess);
- } on Exception catch (err, stackTrace) {
- completer.completeError(err, stackTrace);
- }
-
- return completer.future;
- }
-
- /// See [fidl.ComponentContext#getEntityResolver].
- Future<EntityResolverClient> getEntityResolver() async {
- if (_entityResolver.proxy.ctrl.isBound) {
- return _entityResolver;
- }
-
- Completer<EntityResolverClient> completer =
- Completer<EntityResolverClient>();
-
- try {
- await bound;
- } on Exception catch (err, stackTrace) {
- completer.completeError(err, stackTrace);
- }
-
- // ignore: unawaited_futures
- proxy.ctrl.error.then((ProxyError err) {
- if (!completer.isCompleted) {
- completer.completeError(err);
- }
- });
-
- // ignore: unawaited_futures
- _entityResolver.proxy.ctrl.error.then((ProxyError err) {
- if (!completer.isCompleted) {
- completer.completeError(err);
- }
- });
-
- try {
- proxy.getEntityResolver(_entityResolver.proxy.ctrl.request());
- } on Exception catch (err, stackTrace) {
- completer.completeError(err, stackTrace);
- }
-
- scheduleMicrotask(() {
- if (!completer.isCompleted) {
- completer.complete(_entityResolver);
- }
- });
-
- return completer.future;
- }
-
- /// Obtain a named message queue for receiving messages.
- MessageQueueClient obtainMessageQueue(
- {@required String name,
- @required MessageReceiverCallback onMessage,
- @required MessageQueueErrorCallback onConnectionError}) {
- var mq = MessageQueueClient(
- onMessage: onMessage, onConnectionError: onConnectionError);
- proxy.obtainMessageQueue(name, mq.newRequest());
- return mq;
- }
-
- /// Obtain a message queue sender from a token.
- MessageSenderClient getMessageSender(
- {@required String queueToken,
- @required MessageSenderErrorCallback onConnectionError}) {
- var sender = MessageSenderClient(onConnectionError: onConnectionError);
- proxy.getMessageSender(queueToken, sender.newRequest());
- return sender;
- }
-
- /// Connect to an agent
- Future<fidl.ServiceProviderProxy> connectToAgent(String url) {
- Completer<fidl.ServiceProviderProxy> serviceCompleter =
- Completer<fidl.ServiceProviderProxy>();
-
- // Connect to the agent and save off the agent controller proxy to be
- // closed on terminate
- fidl.ServiceProviderProxy serviceProviderProxy =
- fidl.ServiceProviderProxy();
- serviceProviderProxy.ctrl.error.then((ProxyError err) {
- if (!serviceCompleter.isCompleted) {
- serviceCompleter.completeError(err);
- }
- });
-
- fidl.AgentControllerProxy agentControllerProxy =
- fidl.AgentControllerProxy();
- _agentControllers.add(agentControllerProxy);
- agentControllerProxy.ctrl.error.then((ProxyError err) {
- if (!serviceCompleter.isCompleted) {
- serviceCompleter.completeError(err);
- }
- });
-
- proxy.connectToAgent(
- url,
- serviceProviderProxy.ctrl.request(),
- agentControllerProxy.ctrl.request(),
- );
-
- scheduleMicrotask(() {
- if (!serviceCompleter.isCompleted) {
- serviceCompleter.complete(serviceProviderProxy);
- }
- });
-
- return serviceCompleter.future;
- }
-
- /// See [fidl.ComponentContext#getPackageName].
- Future<String> getPackageName() {
- Completer<String> completer = Completer<String>();
- try {
- proxy.getPackageName(completer.complete);
- } on Exception catch (err, stackTrace) {
- completer.completeError(err, stackTrace);
- }
- return completer.future;
- }
-
- void _handleConnectionError() {
- log.warning('ComponentContextClient connection error');
- }
-
- void _handleBind() {
- log.fine('proxy ready');
- _bind.complete(null);
- }
-
- void _handleUnbind() {
- log.fine('proxy unbound');
- }
-
- void _handleClose() {
- log.fine('proxy closed');
-
- for (fidl.AgentControllerProxy p in _agentControllers) {
- p.ctrl.close();
- }
- }
-
- /// Closes the underlying proxy connection, should be called as a response to
- /// Lifecycle::terminate (see https://goo.gl/MmZ2dc).
- Future<Null> terminate() async {
- log.info('terminate called');
- proxy.ctrl.close();
- return;
- }
-}
diff --git a/public/lib/component/dart/lib/src/message_queue_client.dart b/public/lib/component/dart/lib/src/message_queue_client.dart
deleted file mode 100644
index 87b3b56..0000000
--- a/public/lib/component/dart/lib/src/message_queue_client.dart
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:async';
-import 'dart:typed_data';
-
-import 'package:fidl_fuchsia_modular/fidl.dart';
-import 'package:fidl/fidl.dart';
-import 'package:zircon/zircon.dart';
-import 'package:fidl_fuchsia_mem/fidl.dart' as fuchsia_mem;
-import 'package:meta/meta.dart';
-
-/// [MessageQueueClient] will forward new messages to a function of this type,
-/// along with an [ack] callback that the user must call on receipt of the
-/// message.
-typedef MessageReceiverCallback = void Function(
- Uint8List message, void Function() ack);
-
-/// Possible error codes while listening for new messages.
-enum MessageQueueError {
- /// Message queue is not available. This error isn't expected to happen during
- /// normal function; it is the catch-all IPC-level error.
- unavailable
-}
-
-/// [MessageQueueClient] errors are reported to this callback type.
-typedef MessageQueueErrorCallback = void Function(
- MessageQueueError reason, String errMsg);
-
-/// Helper class for receiving messages on a given message queue.
-class MessageQueueClient extends MessageReader {
- MessageQueueProxy _queue;
- final MessageReaderBinding _readerBinding = MessageReaderBinding();
-
- /// [onMessage] is called when there is a new message.
- final MessageReceiverCallback onMessage;
-
- /// [onConnectionError] is called with an error code when there is an
- /// out-of-band error.
- final MessageQueueErrorCallback onConnectionError;
-
- /// Constructor. An error callback must be supplied which is called when the
- /// MessageQueue is no longer available (it may have been deleted, or it may
- /// not have existed in the first place). The supplied receiver callback is
- /// called there are new messages to process, and an acknowledgement callback
- /// is supplied to the receiver callback, who calls it to say that the message
- /// has been processed, so it won't be delivered again in case there are
- /// failures.
- MessageQueueClient({
- @required this.onMessage,
- @required this.onConnectionError,
- }) : assert(onConnectionError != null),
- assert(onMessage != null);
-
- /// Binds a new MessageQueue proxy and returns the request-side interface.
- InterfaceRequest<MessageQueue> newRequest() {
- _queue?.ctrl?.close();
- _queue ??= MessageQueueProxy();
- _queue.ctrl.error.then((ProxyError err) {
- if (onConnectionError != null) {
- onConnectionError(MessageQueueError.unavailable,
- 'MessageQueue is no longer available');
- }
- });
- var request = _queue.ctrl.request();
- _queue.registerReceiver(_readerBinding.wrap(this));
- return request;
- }
-
- /// Get a token for this message queue. Agents can use this token to register
- /// for triggers. Components can use this token to send message over this
- /// message queue.
- Future<String> getToken() {
- assert(_queue.ctrl.isBound);
-
- Completer<String> result = Completer();
- _queue.getToken((String token) {
- result.complete(token);
- });
- return result.future;
- }
-
- /// Closes the [MessageQueue] binding and stops receiving any new messages by
- /// closing the underlying [MessageReader] interface.
- void close() {
- _queue?.ctrl?.close();
- _queue = null;
- _readerBinding.close();
- }
-
- /// Not public; implements [MessageReader.onReceive].
- @override
- void onReceive(fuchsia_mem.Buffer message, void Function() ack) {
- var dataVmo = SizedVmo(message.vmo.handle, message.size);
- var readResult = dataVmo.read(message.size);
- dataVmo.close();
- onMessage.call(readResult.bytesAsUint8List(), ack);
- }
-}
diff --git a/public/lib/component/dart/lib/src/message_sender_client.dart b/public/lib/component/dart/lib/src/message_sender_client.dart
deleted file mode 100644
index a0b4c2e..0000000
--- a/public/lib/component/dart/lib/src/message_sender_client.dart
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert' show utf8;
-import 'dart:typed_data';
-
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_mem/fidl.dart' as fuchsia_mem;
-import 'package:fidl_fuchsia_modular/fidl.dart';
-import 'package:meta/meta.dart';
-import 'package:zircon/zircon.dart';
-
-/// Possible out-of-band error codes while using a message sender.
-enum MessageSenderError {
- /// Message sender is no longer available. This error happens if the message
- /// queue was deleted, or the supplied token was not valid in the first place.
- unavailable
-}
-
-/// This is the function type that [MessageSenderClient] accepts for reporting
-/// out-of-band errors.
-typedef MessageSenderErrorCallback = void Function(
- MessageSenderError reason, String errMsg);
-
-/// Wrapper class for the fuchsia.modular.MessageSender FIDL interface. This
-/// class provides a more convenient interface for sending messages.
-class MessageSenderClient {
- MessageSenderProxy _messageSenderProxy;
- MessageSenderErrorCallback _onConnectionError;
-
- /// The supplied error callback is called when the token or message queue
- /// no longer exists, or if the token is invalid.
- MessageSenderClient({@required MessageSenderErrorCallback onConnectionError})
- : assert(onConnectionError != null) {
- _onConnectionError = onConnectionError;
- }
-
- /// Will encode the given [message] as utf8 before sending the bytes over.
- /// TODO(MI4-1106): In the future there will be error handling in case
- /// [sendString] fails.
- void sendString(String message) {
- sendUint8List(Uint8List.fromList(utf8.encode(message)));
- }
-
- /// Send the given [message].
- void sendUint8List(Uint8List message) {
- _messageSenderProxy.send(fuchsia_mem.Buffer(
- vmo: SizedVmo.fromUint8List(message),
- size: message.length,
- ));
- }
-
- /// Close the underlying MessageSenderProxy.
- void close() {
- _messageSenderProxy?.ctrl?.close();
- }
-
- /// Binds a new MessageSenderProxy to this class and returns the request-side.
- /// Closes the previously bound proxy if one exists.
- InterfaceRequest<MessageSender> newRequest() {
- if (_messageSenderProxy != null && _messageSenderProxy.ctrl.isBound) {
- _messageSenderProxy.ctrl.close();
- }
-
- _messageSenderProxy = MessageSenderProxy();
- _messageSenderProxy.ctrl.error.then((ProxyError err) {
- if (_onConnectionError != null) {
- _onConnectionError(MessageSenderError.unavailable,
- 'MessageSender not available for the provided token.');
- }
- });
- return _messageSenderProxy.ctrl.request();
- }
-}
diff --git a/public/lib/component/dart/lib/src/message_sender_client_async.dart b/public/lib/component/dart/lib/src/message_sender_client_async.dart
deleted file mode 100644
index abd10d2..0000000
--- a/public/lib/component/dart/lib/src/message_sender_client_async.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:async';
-import 'dart:convert' show utf8;
-import 'dart:typed_data';
-
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_mem/fidl_async.dart' as fuchsia_mem;
-import 'package:fidl_fuchsia_modular/fidl_async.dart';
-import 'package:zircon/zircon.dart';
-
-/// Wrapper class for the async fuchsia.modular.MessageSender FIDL interface.
-/// This class provides a more convenient interface for sending messages.
-/// TODO: Rename to MessageSenderClient once all relevant code switched to
-/// the async fidl bindings.
-class MessageSenderClientAsync {
- MessageSenderProxy _messageSenderProxy;
-
- /// The supplied error callback is called when the token or message queue
- /// no longer exists, or if the token is invalid.
- MessageSenderClientAsync();
-
- /// Will encode the given [message] as utf8 before sending the bytes over.
- /// TODO(MI4-1106): In the future there will be error handling in case
- /// [sendString] fails.
- Future<void> sendString(String message) {
- return sendUint8List(Uint8List.fromList(utf8.encode(message)));
- }
-
- /// Send the given [message].
- Future<void> sendUint8List(Uint8List message) {
- return _messageSenderProxy.send(fuchsia_mem.Buffer(
- vmo: SizedVmo.fromUint8List(message),
- size: message.length,
- ));
- }
-
- /// Close the underlying MessageSenderProxy.
- void close() {
- _messageSenderProxy?.ctrl?.close();
- }
-
- /// Binds a new MessageSenderProxy to this class and returns the request-side.
- /// Closes the previously bound proxy if one exists.
- InterfaceRequest<MessageSender> newRequest() {
- if (_messageSenderProxy != null && _messageSenderProxy.ctrl.isBound) {
- _messageSenderProxy.ctrl.close();
- }
-
- _messageSenderProxy = MessageSenderProxy();
- return _messageSenderProxy.ctrl.request();
- }
-}
diff --git a/public/lib/component/dart/pubspec.yaml b/public/lib/component/dart/pubspec.yaml
deleted file mode 100644
index e69de29..0000000
--- a/public/lib/component/dart/pubspec.yaml
+++ /dev/null
diff --git a/public/lib/entity/dart/BUILD.gn b/public/lib/entity/dart/BUILD.gn
deleted file mode 100644
index a0aa619..0000000
--- a/public/lib/entity/dart/BUILD.gn
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/dart/dart_library.gni")
-
-dart_library("dart") {
- package_name = "lib.entity.dart"
-
- sdk_category = "partner"
-
- sources = [
- "entity.dart",
- "src/entity_client.dart",
- "src/entity_resolver_client.dart",
- ]
-
- deps = [
- "//sdk/fidl/fuchsia.modular",
- "//third_party/dart-pkg/pub/json_schema",
- "//topaz/public/dart/fidl",
- "//topaz/public/lib/app/dart",
- ]
-}
diff --git a/public/lib/entity/dart/analysis_options.yaml b/public/lib/entity/dart/analysis_options.yaml
deleted file mode 100644
index 54917c0..0000000
--- a/public/lib/entity/dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2017 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-include: ../../../analysis_options.yaml
diff --git a/public/lib/entity/dart/lib/entity.dart b/public/lib/entity/dart/lib/entity.dart
deleted file mode 100644
index ffd07b1..0000000
--- a/public/lib/entity/dart/lib/entity.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/entity_client.dart';
-export 'src/entity_resolver_client.dart';
diff --git a/public/lib/entity/dart/lib/src/entity_client.dart b/public/lib/entity/dart/lib/src/entity_client.dart
deleted file mode 100644
index ce3bff4..0000000
--- a/public/lib/entity/dart/lib/src/entity_client.dart
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:async';
-import 'dart:convert';
-
-import 'package:fidl/fidl.dart';
-import 'package:fidl_fuchsia_mem/fidl.dart' as fuchsia_mem;
-import 'package:fidl_fuchsia_modular/fidl.dart' as fidl;
-import 'package:json_schema/json_schema.dart' as json_schema;
-import 'package:lib.app.dart/logging.dart';
-import 'package:zircon/zircon.dart';
-
-/// Provides an idiomatic way to access and type-validate data from an [fidl.Entity].
-class EntityClient {
- /// The underlying [Proxy] used to send client requests to the
- /// [fidl.Entity] service.
- final fidl.EntityProxy proxy;
-
- /// Constructor.
- EntityClient() : proxy = fidl.EntityProxy() {
- proxy.ctrl
- ..onBind = _handleBind
- ..onClose = _handleClose
- ..onConnectionError = _handleConnectionError
- ..onUnbind = _handleUnbind;
- }
-
- /// Constructor.
- EntityClient.fromEntity(this.proxy);
-
- /// List of types this entity supports.
- Future<List<String>> getTypes() {
- Completer<List<String>> result = Completer<List<String>>();
- proxy.getTypes(result.complete);
- return result.future;
- }
-
- /// Given one of the types returned from [getTypes], this method gets the data
- /// for it, validates it using [jsonTypeSchema], and returns non-null data if
- /// the data is valid.
- Future<String> getValidatedData(String type, String jsonTypeSchema) async {
- String data = await getData(type);
- json_schema.Schema schema =
- await json_schema.Schema.createSchema(json.decode(jsonTypeSchema));
- if (data != null && schema.validate(jsonTypeSchema)) {
- return data;
- }
- return null;
- }
-
- Future<fuchsia_mem.Buffer> _getVmoData(String type) {
- Completer<fuchsia_mem.Buffer> result = Completer<fuchsia_mem.Buffer>();
- proxy.getData(type, result.complete);
- return result.future;
- }
-
- /// Returns the data associated with the given type without validating it.
- Future<String> getData(String type) async {
- var buffer = await _getVmoData(type);
- var dataVmo = SizedVmo(buffer.vmo.handle, buffer.size);
- var data = dataVmo.read(buffer.size);
- dataVmo.close();
- return utf8.decode(data.bytesAsUint8List());
- }
-
- /// Closes the underlying proxy connection, should be called as a response to
- /// Lifecycle::terminate (see https://goo.gl/MmZ2dc).
- Future<Null> terminate() async {
- log.info('terminate called');
- proxy.ctrl.close();
- return;
- }
-
- void _handleBind() {
- log.fine('proxy ready');
- }
-
- void _handleUnbind() {
- log.fine('proxy unbound');
- }
-
- void _handleClose() {
- log.fine('proxy closed');
- }
-
- void _handleConnectionError() {
- log.warning('Entity connection error');
- }
-}
diff --git a/public/lib/entity/dart/lib/src/entity_resolver_client.dart b/public/lib/entity/dart/lib/src/entity_resolver_client.dart
deleted file mode 100644
index 212e61e..0000000
--- a/public/lib/entity/dart/lib/src/entity_resolver_client.dart
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:fidl/fidl.dart';
-import 'package:lib.app.dart/logging.dart';
-import 'package:fidl_fuchsia_modular/fidl.dart' as fidl;
-
-import 'entity_client.dart';
-
-/// Client wrapper for [fidl.EntityResolver].
-class EntityResolverClient {
- /// The underlying [Proxy] used to send client requests to the
- /// [fidl.EntityResolver] service.
- final fidl.EntityResolverProxy proxy = fidl.EntityResolverProxy();
-
- final List<EntityClient> _entities = <EntityClient>[];
-
- /// Constructor.
- EntityResolverClient() {
- proxy.ctrl
- ..onBind = _handleBind
- ..onClose = _handleClose
- ..onConnectionError = _handleConnectionError
- ..onUnbind = _handleUnbind;
- }
-
- /// A future that completes when the [proxy] is bound.
- Future<Null> get bound => _bind.future;
- final Completer<Null> _bind = Completer<Null>();
-
- /// See [fidl.EntityResolver#resolveEntity].
- Future<EntityClient> resolveEntity(String ref) async {
- Completer<EntityClient> completer = Completer<EntityClient>();
-
- try {
- await bound;
- } on Exception catch (err, stackTrace) {
- completer.completeError(err, stackTrace);
- }
-
- EntityClient entity = EntityClient();
-
- // ignore: unawaited_futures
- proxy.ctrl.error.then((ProxyError err) {
- if (!completer.isCompleted) {
- completer.completeError(err);
- }
- });
-
- // ignore: unawaited_futures
- entity.proxy.ctrl.error.then((ProxyError err) {
- if (!completer.isCompleted) {
- completer.completeError(err);
- }
- });
-
- _entities.add(entity); // don't forget to close.
-
- try {
- proxy.resolveEntity(ref, entity.proxy.ctrl.request());
- } on Exception catch (err, stackTrace) {
- completer.completeError(err, stackTrace);
- }
-
- scheduleMicrotask(() {
- if (!completer.isCompleted) {
- completer.complete(entity);
- }
- });
-
- return completer.future;
- }
-
- /// Closes the underlying proxy connection, should be called as a response to
- /// Lifecycle::terminate (see https://goo.gl/MmZ2dc).
- Future<Null> terminate() async {
- log.info('terminate called');
- proxy.ctrl.close();
- return;
- }
-
- void _handleBind() {
- log.fine('proxy ready');
- _bind.complete(null);
- }
-
- void _handleUnbind() {
- log.fine('proxy unbound');
- }
-
- void _handleClose() {
- log.fine('proxy closed');
-
- for (EntityClient entity in _entities) {
- entity.terminate();
- }
- }
-
- void _handleConnectionError() {
- log.severe('EntityResolverClient connection error');
- }
-}
diff --git a/public/lib/entity/dart/pubspec.yaml b/public/lib/entity/dart/pubspec.yaml
deleted file mode 100644
index e69de29..0000000
--- a/public/lib/entity/dart/pubspec.yaml
+++ /dev/null
diff --git a/public/lib/schemas/dart/BUILD.gn b/public/lib/schemas/dart/BUILD.gn
deleted file mode 100644
index 7faab02..0000000
--- a/public/lib/schemas/dart/BUILD.gn
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright 2018 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/dart/dart_library.gni")
-import("//build/dart/test.gni")
-
-dart_library("dart") {
- package_name = "lib.schemas.dart"
-
- sdk_category = "partner"
- sources_required = false
-
- sources = [
- "com.fuchsia.color.dart",
- "com.fuchsia.contact.dart",
- "com.fuchsia.documents.dart",
- "com.fuchsia.intent.dart",
- "com.fuchsia.status.dart",
- "com/fuchsia/codelab/codelab.dart",
- "com/fuchsia/codelab/finance/finance_entity_codec.dart",
- "com/fuchsia/codelab/lyrics/lyrics_entity_codec.dart",
- "com/fuchsia/codelab/recipe/recipe_entity_codec.dart",
- "com/fuchsia/media/asset_specifier/asset_specifier_entity_codec.dart",
- "com/fuchsia/media/asset_specifier/asset_specifier_entity_data.dart",
- "com/fuchsia/media/captions/captions_entity_codec.dart",
- "com/fuchsia/media/media.dart",
- "com/fuchsia/media/progress/media_progress_entity_codec.dart",
- "com/fuchsia/media/progress/media_progress_entity_data.dart",
- "com/google/youtube/video_id_entity_codec.dart",
- "entity_codec.dart",
- "src/com.fuchsia.color/color_entity_codec.dart",
- "src/com.fuchsia.color/color_entity_data.dart",
- "src/com.fuchsia.contact/contact_entity_codec.dart",
- "src/com.fuchsia.contact/contact_entity_data.dart",
- "src/com.fuchsia.contact/email_entity_codec.dart",
- "src/com.fuchsia.contact/email_entity_data.dart",
- "src/com.fuchsia.contact/filter_entity_codec.dart",
- "src/com.fuchsia.contact/filter_entity_data.dart",
- "src/com.fuchsia.contact/phone_number_entity_codec.dart",
- "src/com.fuchsia.contact/phone_number_entity_data.dart",
- "src/com.fuchsia.documents/documents_id_codec.dart",
- "src/com.fuchsia.documents/documents_id_entity_data.dart",
- "src/com.fuchsia.intent/intent_entity_codec.dart",
- "src/com.fuchsia.intent/intent_entity_data.dart",
- "src/com.fuchsia.status/status_entity_codec.dart",
- "src/com.fuchsia.status/status_entity_data.dart",
- "src/entity_codec.dart",
- "src/parse_int.dart",
- "src/string_list_entity_codec.dart",
- # Including these sources triggers analysis errors
- # "com.fuchsia.location.dart",
- # "com/google/youtube/json_entity_codec.dart",
- # "src/com.fuchsia.location/geolocation_entity_data.dart",
- # "src/com.fuchsia.location/street_location_entity_data.dart",
- # "src/com.fuchsia.location/street_location_entity_codec.dart",
- # "src/com.fuchsia.location/geolocation_entity_codec.dart",
- ]
-
- deps = [
- "//third_party/dart-pkg/pub/json_schema",
- "//topaz/public/lib/app/dart",
- ]
-}
-
-dart_test("dart_schema_tests") {
- sources = [
- "entity_codec_test.dart",
- ]
-
- deps = [
- "//third_party/dart-pkg/git/flutter/packages/flutter_test",
- "//third_party/dart-pkg/pub/test",
- "//topaz/public/lib/schemas/dart",
- ]
-}
diff --git a/public/lib/schemas/dart/README.md b/public/lib/schemas/dart/README.md
deleted file mode 100644
index e69de29..0000000
--- a/public/lib/schemas/dart/README.md
+++ /dev/null
diff --git a/public/lib/schemas/dart/analysis_options.yaml b/public/lib/schemas/dart/analysis_options.yaml
deleted file mode 100644
index 28306ea..0000000
--- a/public/lib/schemas/dart/analysis_options.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-include: ../../../analysis_options.yaml
diff --git a/public/lib/schemas/dart/lib/com.fuchsia.color.dart b/public/lib/schemas/dart/lib/com.fuchsia.color.dart
deleted file mode 100644
index 9d2e709..0000000
--- a/public/lib/schemas/dart/lib/com.fuchsia.color.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/com.fuchsia.color/color_entity_codec.dart';
diff --git a/public/lib/schemas/dart/lib/com.fuchsia.contact.dart b/public/lib/schemas/dart/lib/com.fuchsia.contact.dart
deleted file mode 100644
index 3f045db..0000000
--- a/public/lib/schemas/dart/lib/com.fuchsia.contact.dart
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/com.fuchsia.contact/contact_entity_codec.dart';
-export 'src/com.fuchsia.contact/contact_entity_data.dart';
-export 'src/com.fuchsia.contact/email_entity_codec.dart';
-export 'src/com.fuchsia.contact/email_entity_data.dart';
-export 'src/com.fuchsia.contact/filter_entity_codec.dart';
-export 'src/com.fuchsia.contact/filter_entity_data.dart';
-export 'src/com.fuchsia.contact/phone_number_entity_codec.dart';
-export 'src/com.fuchsia.contact/phone_number_entity_data.dart';
diff --git a/public/lib/schemas/dart/lib/com.fuchsia.documents.dart b/public/lib/schemas/dart/lib/com.fuchsia.documents.dart
deleted file mode 100644
index 6864076..0000000
--- a/public/lib/schemas/dart/lib/com.fuchsia.documents.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/com.fuchsia.documents/documents_id_codec.dart';
diff --git a/public/lib/schemas/dart/lib/com.fuchsia.intent.dart b/public/lib/schemas/dart/lib/com.fuchsia.intent.dart
deleted file mode 100644
index 9a4b761..0000000
--- a/public/lib/schemas/dart/lib/com.fuchsia.intent.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/com.fuchsia.intent/intent_entity_codec.dart';
-export 'src/com.fuchsia.intent/intent_entity_data.dart';
diff --git a/public/lib/schemas/dart/lib/com.fuchsia.location.dart b/public/lib/schemas/dart/lib/com.fuchsia.location.dart
deleted file mode 100644
index 22faec0..0000000
--- a/public/lib/schemas/dart/lib/com.fuchsia.location.dart
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/com.fuchsia.location/geolocation_entity_codec.dart';
-export 'src/com.fuchsia.location/geolocation_entity_data.dart';
-export 'src/com.fuchsia.location/street_location_entity_codec.dart';
-export 'src/com.fuchsia.location/street_location_entity_data.dart';
\ No newline at end of file
diff --git a/public/lib/schemas/dart/lib/com.fuchsia.status.dart b/public/lib/schemas/dart/lib/com.fuchsia.status.dart
deleted file mode 100644
index 48628c7..0000000
--- a/public/lib/schemas/dart/lib/com.fuchsia.status.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'src/com.fuchsia.status/status_entity_codec.dart';
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/codelab/codelab.dart b/public/lib/schemas/dart/lib/com/fuchsia/codelab/codelab.dart
deleted file mode 100644
index 3ad24ce..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/codelab/codelab.dart
+++ /dev/null
@@ -1,7 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'finance/finance_entity_codec.dart';
-export 'lyrics/lyrics_entity_codec.dart';
-export 'recipe/recipe_entity_codec.dart';
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/codelab/finance/finance_entity_codec.dart b/public/lib/schemas/dart/lib/com/fuchsia/codelab/finance/finance_entity_codec.dart
deleted file mode 100644
index fee66a6..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/codelab/finance/finance_entity_codec.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-const String _kFinanceEntityUri = 'com.fuchsia.codelab.finance';
-
-/// Convert list of stock ticker values to a form passable over a Link between
-/// modules.
-class FinanceEntityCodec extends StringListEntityCodec {
- /// Constuctor assigns the Entity type.
- FinanceEntityCodec() : super(_kFinanceEntityUri);
-}
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/codelab/lyrics/lyrics_entity_codec.dart b/public/lib/schemas/dart/lib/com/fuchsia/codelab/lyrics/lyrics_entity_codec.dart
deleted file mode 100644
index 95f84a6..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/codelab/lyrics/lyrics_entity_codec.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-const String _kLyricsEntityUri = 'com.fuchsia.codelab.lyrics';
-
-/// Convert list of stock ticker values to a form passable over a Link between
-/// modules.
-class LyricsEntityCodec extends StringListEntityCodec {
- /// Constuctor assigns the Entity type.
- LyricsEntityCodec() : super(_kLyricsEntityUri);
-}
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/codelab/recipe/recipe_entity_codec.dart b/public/lib/schemas/dart/lib/com/fuchsia/codelab/recipe/recipe_entity_codec.dart
deleted file mode 100644
index 2d79598..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/codelab/recipe/recipe_entity_codec.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-const String _kRecipeEntityUri = 'com.fuchsia.codelab.recipe';
-
-/// Convert a Recipe values to a form passable over a Link between
-/// modules.
-class RecipeEntityCodec extends StringListEntityCodec {
- /// Constuctor assigns the Entity type.
- RecipeEntityCodec() : super(_kRecipeEntityUri);
-}
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/media/asset_specifier/asset_specifier_entity_codec.dart b/public/lib/schemas/dart/lib/com/fuchsia/media/asset_specifier/asset_specifier_entity_codec.dart
deleted file mode 100644
index 0d3398e..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/media/asset_specifier/asset_specifier_entity_codec.dart
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert' show json;
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-import 'asset_specifier_entity_data.dart';
-
-const String _kAssetSpecifierEntityUri = 'com.fucshia.media.asset_specifier';
-const String _kAssetTypeKey = 'asset_type';
-const String _kAssetUriKey = 'asset_uri';
-
-const String _kMovieType = 'movie';
-const String _kSongType = 'song';
-const String _kPlaylistType = 'playlist';
-
-/// Convert an AssetSpecifierEntityData to a form passable over a Link between
-/// processes. For now, Asset is only used in video player and is therefore
-/// always of type movie.
-class AssetSpecifierEntityCodec extends EntityCodec<AssetSpecifierEntityData> {
- /// Constuctor assigns the proper values to en/decode VideoProgress objects.
- AssetSpecifierEntityCodec()
- : super(
- type: _kAssetSpecifierEntityUri,
- encode: _encode,
- decode: _decode,
- );
-
- static String _encode(AssetSpecifierEntityData asset) {
- log.finer('Convert Asset to JSON: $asset');
- if (asset == null || asset.uri == null) {
- return 'null';
- }
- String assetType;
- switch (asset.type) {
- case AssetType.movie:
- assetType = _kMovieType;
- break;
- case AssetType.song:
- assetType = _kSongType;
- break;
- case AssetType.playlist:
- assetType = _kPlaylistType;
- break;
- default:
- throw const FormatException(
- 'Converting AssetSpecifierEntityData with unsupported type');
- }
- return json.encode(
- <String, dynamic>{_kAssetTypeKey: assetType, _kAssetUriKey: asset.uri});
- }
-
- static AssetSpecifierEntityData _decode(Object data) {
- log.finer('Convert to Asset from JSON: $data');
- if (data == null) {
- return null;
- }
- if (data is! String) {
- throw const FormatException('Decoding Entity with unsupported type');
- }
- String encoded = data;
- if (encoded.isEmpty) {
- throw const FormatException('Decoding Entity with empty string');
- }
- if (encoded == 'null') {
- return null;
- }
- dynamic decode = json.decode(encoded);
- if (decode == null || decode is! Map) {
- throw const FormatException('Decoding Entity with invalid data');
- }
- Map<String, dynamic> map = decode.cast<String, dynamic>();
- if (map[_kAssetTypeKey] is! String) {
- throw const FormatException('Converting Entity with invalid values');
- }
- switch (map[_kAssetTypeKey]) {
- case _kMovieType:
- return _movieFromMap(map);
- default:
- throw FormatException(
- 'Converting AssetSpecifierEntityData with unsupported type: ${map[_kAssetTypeKey]}');
- }
- }
-
- static AssetSpecifierEntityData _movieFromMap(Map<String, dynamic> map) {
- if (map[_kAssetUriKey] == null || map[_kAssetUriKey] is! String) {
- throw FormatException(
- 'Converting AssetSpecifierEntityData with invalid Uri: ${map[_kAssetUriKey]}');
- }
- String uri = map[_kAssetUriKey];
- if (uri == 'null') {
- throw const FormatException(
- 'Converting AssetSpecifierEntityData with null Uri');
- }
- return AssetSpecifierEntityData.movie(uri: uri);
- }
-}
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/media/asset_specifier/asset_specifier_entity_data.dart b/public/lib/schemas/dart/lib/com/fuchsia/media/asset_specifier/asset_specifier_entity_data.dart
deleted file mode 100644
index acdc63f..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/media/asset_specifier/asset_specifier_entity_data.dart
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-/// The asset types.
-enum AssetType {
- /// Individual assets containing both audio and video.
- movie,
-
- /// Individual assets containing only audio.
- song,
-
- /// Composite assets that consist of a list of other assets.
- playlist,
-
- /// Remote player
- remote,
-}
-
-/// Describes the location of an Asset. The Asset could be a movie, song or a
-/// playlist, which is actually the collection of AssetSpecifiers.
-class AssetSpecifierEntityData {
- /// String conversion of the Uri of the asset. Must be null for playlists,
- /// required for all other asset types.
- final String uri;
-
- /// Type of the asset.
- final AssetType type;
-
- /// Children of the playlist asset. Must be null for other asset types.
- final List<AssetSpecifierEntityData> children;
-
- /// Constructs an asset describing a movie.
- AssetSpecifierEntityData.movie({@required this.uri})
- : assert(uri != null),
- type = AssetType.movie,
- children = null;
-
- /// Constructs an asset describing a song.
- AssetSpecifierEntityData.song({@required this.uri})
- : type = AssetType.song,
- children = null;
-
- /// Constructs an asset describing a playlist.
- AssetSpecifierEntityData.playlist({
- @required this.children,
- }) : assert(children.isNotEmpty),
- assert(children.every((AssetSpecifierEntityData c) =>
- c.type == AssetType.movie || c.type == AssetType.song)),
- type = AssetType.playlist,
- uri = null;
-}
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/media/captions/captions_entity_codec.dart b/public/lib/schemas/dart/lib/com/fuchsia/media/captions/captions_entity_codec.dart
deleted file mode 100644
index 01c670e..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/media/captions/captions_entity_codec.dart
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert' show json;
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-const String _kCaptionsEntityUri = 'com.fuchsia.captions';
-
-// TODO MS-1308 Move to public entities location
-
-/// Convert a list of captions to a form passable over a Link between processes.
-class CaptionsEntityCodec extends EntityCodec<List<String>> {
- /// Constuctor assigns the proper values to en/decode a list of captions.
- CaptionsEntityCodec()
- : super(
- type: _kCaptionsEntityUri,
- encode: _encode,
- decode: _decode,
- );
-
- static String _encode(List<String> captions) {
- log.fine('Convert captions to json: $captions');
- if (captions == null || captions.isEmpty) {
- return 'null';
- }
- return json.encode(captions);
- }
-
- static List<String> _decode(Object data) {
- log.fine('Convert to list of captions from json: $data');
- if (data == null) {
- return null;
- }
- if (data is! String) {
- throw const FormatException('Decoding Entity with unsupported type');
- }
- String encoded = data;
- if (encoded.isEmpty) {
- throw const FormatException('Decoding Entity with empty string');
- }
- if (encoded == 'null') {
- return null;
- }
- dynamic decoded = json.decode(encoded);
- if (decoded == null || decoded is! List) {
- throw const FormatException('Decoding Entity with invalid data');
- }
- List<String> list = decoded.cast<String>();
- for (String obj in list) {
- if (obj is! String) {
- throw const FormatException('Captions contained non-String data');
- }
- }
- return list;
- }
-}
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/media/media.dart b/public/lib/schemas/dart/lib/com/fuchsia/media/media.dart
deleted file mode 100644
index ebaf017..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/media/media.dart
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-export 'asset_specifier/asset_specifier_entity_codec.dart';
-export 'asset_specifier/asset_specifier_entity_data.dart';
-
-export 'captions/captions_entity_codec.dart';
-
-export 'progress/media_progress_entity_codec.dart';
-export 'progress/media_progress_entity_data.dart';
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/media/progress/media_progress_entity_codec.dart b/public/lib/schemas/dart/lib/com/fuchsia/media/progress/media_progress_entity_codec.dart
deleted file mode 100644
index 6393e81..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/media/progress/media_progress_entity_codec.dart
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert' show json;
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-import 'media_progress_entity_data.dart';
-
-const String _kDurationKey = 'duration_msec';
-const String _kProgressKey = 'normalized_progress';
-
-/// Codec for reading/writing MediaProgress Entities to a Link.
-// TODO(MS-1319): move to //topaz/public/lib/schemas
-class MediaProgressEntityCodec extends EntityCodec<MediaProgressEntityData> {
- /// Constuctor assigns the proper values to en/decode MediaProgress objects.
- MediaProgressEntityCodec()
- : super(
- type: 'com.fuchsia.media.progress',
- encode: _encode,
- decode: _decode,
- );
-
- // Create a MediaProgress from a json string previously output by encode()
- static MediaProgressEntityData _decode(Object data) {
- log.finer('Convert to MediaProgressEntityData from JSON: $data');
- if (data == null) {
- return null;
- }
- if (data is! String) {
- throw const FormatException('Decoding Entity with unsupported type');
- }
- String encoded = data;
- if (encoded.isEmpty) {
- throw const FormatException('Decoding Entity with empty string');
- }
- if (encoded == 'null') {
- return null;
- }
- dynamic decode = json.decode(encoded);
- if (decode == null || decode is! Map) {
- throw const FormatException('Decoding Entity with invalid data');
- }
- Map<String, dynamic> map = decode.cast<String, dynamic>();
- if (map[_kDurationKey] == null ||
- map[_kDurationKey] is! int ||
- map[_kProgressKey] == null ||
- map[_kProgressKey] is! double) {
- throw const FormatException('Converting Entity with invalid values');
- }
- return MediaProgressEntityData(map[_kDurationKey], map[_kProgressKey]);
- }
-
- // Convert to a json string suitable for sending over a Link
- static String _encode(MediaProgressEntityData progress) {
- log.finer('Convert MediaProgressEntityData to JSON: $progress');
- if (progress == null) {
- return 'null';
- }
- return json.encode(<String, dynamic>{
- _kDurationKey: progress.durationMsec,
- _kProgressKey: progress.normalizedProgress,
- });
- }
-}
diff --git a/public/lib/schemas/dart/lib/com/fuchsia/media/progress/media_progress_entity_data.dart b/public/lib/schemas/dart/lib/com/fuchsia/media/progress/media_progress_entity_data.dart
deleted file mode 100644
index 441b3f4..0000000
--- a/public/lib/schemas/dart/lib/com/fuchsia/media/progress/media_progress_entity_data.dart
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/// Entity for communicating progress of media playback
-class MediaProgressEntityData {
- /// Constructor
- const MediaProgressEntityData(this.durationMsec, this.normalizedProgress);
-
- /// Progress through media in the range [0..1]
- final double normalizedProgress;
-
- /// Full length of the media
- final int durationMsec;
-}
diff --git a/public/lib/schemas/dart/lib/com/google/youtube/json_entity_codec.dart b/public/lib/schemas/dart/lib/com/google/youtube/json_entity_codec.dart
deleted file mode 100644
index 2469b75..0000000
--- a/public/lib/schemas/dart/lib/com/google/youtube/json_entity_codec.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-const String _kJsonEntityUri = 'com.fuchsia.json';
-
-/// Converts a request to set the json into a form passable over a Link between
-/// modules. This is functionally just a pass-through for the string, which
-/// will be interpreted after decoding on the module-side.
-class JsonEntityCodec extends EntityCodec<String> {
- /// Constuctor assigns the proper values to en/decode a the request.
- JsonEntityCodec()
- : super(
- type: _kJsonEntityUri,
- encode: (x) => x,
- decode: (x) => x,
- );
-}
diff --git a/public/lib/schemas/dart/lib/com/google/youtube/video_id_entity_codec.dart b/public/lib/schemas/dart/lib/com/google/youtube/video_id_entity_codec.dart
deleted file mode 100644
index bfb7a35..0000000
--- a/public/lib/schemas/dart/lib/com/google/youtube/video_id_entity_codec.dart
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-const String _kYoutubeVideoIdEntityUri = 'com.fuchsia.youtube.videoid';
-
-/// Convert a request to set the videoID to a form passable over a Link between
-/// modules.
-class VideoIdEntityCodec extends EntityCodec<String> {
- /// Constuctor assigns the proper values to en/decode a the request.
- VideoIdEntityCodec()
- : super(
- type: _kYoutubeVideoIdEntityUri,
- encode: (x) => x,
- decode: (x) => x,
- );
-}
diff --git a/public/lib/schemas/dart/lib/entity_codec.dart b/public/lib/schemas/dart/lib/entity_codec.dart
deleted file mode 100644
index 8f73448..0000000
--- a/public/lib/schemas/dart/lib/entity_codec.dart
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// NOTE: Importers of this file tend to be private implementations for public
-// APIs (e.g, lib.app_driver.dart). It's best to use a pre-defined codec based
-// on the type you are working with by importing this package's files for that
-// type.
-export 'src/entity_codec.dart';
-export 'src/string_list_entity_codec.dart';
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.color/color_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.color/color_entity_codec.dart
deleted file mode 100644
index 4f87d00..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.color/color_entity_codec.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import '../entity_codec.dart';
-import '../parse_int.dart';
-import 'color_entity_data.dart';
-
-export 'color_entity_data.dart';
-
-/// This [EntityCodec] translates Entity source data to and from the structured
-/// [ColorEntityData].
-class ColorEntityCodec extends EntityCodec<ColorEntityData> {
- /// Create an instance of [ColorEntityCodec].
- ColorEntityCodec()
- : super(
- type: 'com.fuchsia.color',
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [ColorEntityData] into a [String].
-String _encode(ColorEntityData data) {
- assert(data != null);
-
- return data.value.toString();
-}
-
-/// Decodes [String] into a structured [ColorEntityData].
-ColorEntityData _decode(String data) {
- assert(data != null);
- assert(data.isNotEmpty);
-
- final int value = parseInt(data);
- return ColorEntityData(value: value);
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.color/color_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.color/color_entity_data.dart
deleted file mode 100644
index 012da9e..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.color/color_entity_data.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-/// Holds strucutred data decoded from the Entity's data.
-class ColorEntityData {
- /// A 32 bit value representing the color.
- final int value;
-
- /// Create a new instance of [ColorEntityData].
- const ColorEntityData({
- @required this.value,
- })
- : assert(value != null);
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/contact_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/contact_entity_codec.dart
deleted file mode 100644
index ab93b68..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/contact_entity_codec.dart
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert';
-
-import 'package:lib.app.dart/logging.dart';
-
-import '../../com.fuchsia.contact.dart';
-import '../entity_codec.dart';
-
-const String _kType = 'com.fuchsia.contact';
-
-/// The [EntityCodec] that translates the [ContactEntityData]
-class ContactEntityCodec extends EntityCodec<ContactEntityData> {
- /// Constructor
- ContactEntityCodec()
- : super(
- type: _kType,
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [ContactEntityData] into a [String]
-String _encode(ContactEntityData contact) {
- Map<String, Object> data = <String, Object>{};
- EmailEntityCodec emailCodec = EmailEntityCodec();
- PhoneNumberEntityCodec phoneCodec = PhoneNumberEntityCodec();
-
- data['id'] = contact.id;
- data['displayName'] = contact.displayName;
- data['givenName'] = contact.givenName;
- data['middleName'] = contact.middleName;
- data['familyName'] = contact.familyName;
- data['photoUrl'] = contact.photoUrl;
- data['emailAddresses'] =
- contact.emailAddresses.map(emailCodec.encode).toList();
- data['phoneNumbers'] = contact.phoneNumbers.map(phoneCodec.encode).toList();
-
- return json.encode(data);
-}
-
-/// Decodes [String] into a structured [ContactEntityData]
-ContactEntityData _decode(String data) {
- if (data == null || data.isEmpty) {
- return null;
- }
-
- try {
- Map<String, dynamic> decodedJson = json.decode(data);
- EmailEntityCodec emailCodec = EmailEntityCodec();
- PhoneNumberEntityCodec phoneNumberCodec = PhoneNumberEntityCodec();
- return ContactEntityData(
- id: decodedJson['id'],
- displayName: decodedJson['displayName'],
- givenName: decodedJson['givenName'] ?? '',
- familyName: decodedJson['familyName'] ?? '',
- middleName: decodedJson['middleName'] ?? '',
- photoUrl: decodedJson['photoUrl'] ?? '',
- emailAddresses: decodedJson['emailAddresses']
- .map((String emailJson) => emailCodec.decode(emailJson))
- .toList(),
- phoneNumbers: decodedJson['phoneNumbers']
- .map((String numberJson) => phoneNumberCodec.decode(numberJson))
- .toList(),
- );
- } on Exception catch (e) {
- // since this is just a first pass, not really going to do too much
- // additional validation here but would like to know if this ever does
- // error out
- log.warning('$_kType entity error when decoding from json string: $json'
- '\nerror: $e');
- rethrow;
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/contact_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/contact_entity_data.dart
deleted file mode 100644
index 4b6b421..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/contact_entity_data.dart
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-import 'email_entity_data.dart';
-import 'phone_number_entity_data.dart';
-
-/// The data for a Contact entity
-class ContactEntityData {
- /// The contact id
- final String id;
-
- /// Full name of contact, usually givenName + familyName
- final String displayName;
-
- /// First name for contact
- final String givenName;
-
- /// Middle name for contact
- final String middleName;
-
- /// Last name for contact
- final String familyName;
-
- /// Email addresses associated with contact
- final List<EmailEntityData> emailAddresses;
-
- /// Phone numbers associated with contact
- final List<PhoneNumberEntityData> phoneNumbers;
-
- /// URL for main contact profile photo;
- final String photoUrl;
-
- /// Constructor
- ContactEntityData({
- @required this.id,
- @required this.displayName,
- this.givenName,
- this.familyName,
- this.middleName,
- this.photoUrl,
- List<EmailEntityData> emailAddresses,
- List<PhoneNumberEntityData> phoneNumbers,
- }) : assert(id != null && id.isNotEmpty),
- assert(displayName != null && displayName.isNotEmpty),
- emailAddresses = List<EmailEntityData>.unmodifiable(
- emailAddresses ?? <EmailEntityData>[]),
- phoneNumbers = List<PhoneNumberEntityData>.unmodifiable(
- phoneNumbers ?? <PhoneNumberEntityData>[]);
-
- /// The primary email is the first entry in the list of emails
- /// Returns null if there is no email for contact
- EmailEntityData get primaryEmail {
- if (emailAddresses.isEmpty) {
- return null;
- } else {
- return emailAddresses[0];
- }
- }
-
- /// The primary phone number is the first entry in the list of phone numbers
- /// Returns null if there is no phone number for contact
- PhoneNumberEntityData get primaryPhoneNumber {
- if (phoneNumbers.isEmpty) {
- return null;
- } else {
- return phoneNumbers[0];
- }
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/email_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/email_entity_codec.dart
deleted file mode 100644
index ce9ec28..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/email_entity_codec.dart
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert';
-
-import 'package:lib.app.dart/logging.dart';
-
-import '../entity_codec.dart';
-import 'email_entity_data.dart';
-
-const String _kType = 'com.fuchsia.contact.email';
-
-/// The [EntityCodec] that translates the [EmailEntityData].
-class EmailEntityCodec extends EntityCodec<EmailEntityData> {
- /// Constructor
- EmailEntityCodec()
- : super(
- type: _kType,
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [EmailEntityData] into a [String].
-String _encode(EmailEntityData email) {
- assert(email != null);
-
- return json.encode(<String, String>{
- 'label': email.label,
- 'value': email.value,
- });
-}
-
-/// Decodes [String] into a structured [EmailEntityData].
-EmailEntityData _decode(String data) {
- assert(data != null);
- assert(data.isNotEmpty);
- try {
- Map<String, String> decodedJson = json.decode(data);
- return EmailEntityData(
- value: decodedJson['value'],
- label: decodedJson['label'] ?? '',
- );
- } on Exception catch (e) {
- // since this is just a first pass, not really going to do too much
- // additional validation here but would like to know if this ever does
- // error out
- log.warning('$_kType entity error when decoding from json string: $json'
- '\nerror: $e');
- rethrow;
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/email_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/email_entity_data.dart
deleted file mode 100644
index 4a57a8f..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/email_entity_data.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-/// The Entity Schema for an email address
-class EmailEntityData {
- /// Email address, e.g. littlePuppyCoco@cute.org
- final String value;
-
- /// Optional label to give for the email, e.g. Work, Personal...
- final String label;
-
- /// Constructor
- EmailEntityData({
- @required this.value,
- this.label,
- }) : assert(value != null && value.isNotEmpty);
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/filter_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/filter_entity_codec.dart
deleted file mode 100644
index d7dabb5..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/filter_entity_codec.dart
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert';
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-import 'filter_entity_data.dart';
-
-/// The [EntityCodec] that translates [FilterEntityData]
-class FilterEntityCodec extends EntityCodec<FilterEntityData> {
- /// Creates an instance of the codec
- FilterEntityCodec()
- : super(
- type: 'com.fuchsia.contact.filter',
- encode: _encode,
- decode: _decode,
- );
-}
-
-String _encode(FilterEntityData entity) {
- if (entity == null) {
- return null;
- }
-
- return json.encode(<String, String>{
- 'prefix': entity.prefix,
- 'detailType': entity.detailType.toString()
- });
-}
-
-FilterEntityData _decode(String data) {
- if (data == null || data.isEmpty) {
- return null;
- }
-
- FilterEntityData filter = FilterEntityData();
- try {
- Map<String, String> decoded = json.decode(data).cast<String, String>();
- filter.prefix = decoded['prefix'];
- DetailType detailType;
- switch (data) {
- case 'email':
- detailType = DetailType.email;
- break;
-
- case 'phoneNumber':
- detailType = DetailType.phoneNumber;
- break;
-
- default:
- detailType = DetailType.custom;
- break;
- }
- filter.detailType = detailType;
- } on Exception catch (err, stackTrace) {
- log.warning('Error parsing FilterEntityData: $err\n$stackTrace');
- }
-
- return filter;
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/filter_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/filter_entity_data.dart
deleted file mode 100644
index 0abd90a..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/filter_entity_data.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/// The type of detail to show with the contact's display name
-enum DetailType {
- /// Primary email of the contact
- email,
-
- /// Primary phone number of the contact
- phoneNumber,
-
- /// Custom contact information
- custom,
-}
-
-/// Data for filtering a list of contacts
-class FilterEntityData {
- /// The prefix used to filter contacts
- String prefix;
-
- /// Detail to show with the contact's display name
- DetailType detailType;
-
- /// Constructor
- FilterEntityData({
- this.prefix = '',
- this.detailType = DetailType.email,
- });
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/phone_number_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/phone_number_entity_codec.dart
deleted file mode 100644
index edf51d1..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/phone_number_entity_codec.dart
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert';
-
-import 'package:lib.app.dart/logging.dart';
-
-import '../../com.fuchsia.contact.dart';
-import '../entity_codec.dart';
-
-const String _kType = 'com.fuchsia.contact.phone';
-
-/// The [EntityCodec] that translates the [PhoneNumberEntityData].
-class PhoneNumberEntityCodec extends EntityCodec<PhoneNumberEntityData> {
- /// Constructor
- PhoneNumberEntityCodec()
- : super(
- type: _kType,
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [PhoneNumberEntityData] into a [String].
-String _encode(PhoneNumberEntityData phone) {
- assert(phone != null);
- return json.encode(<String, String>{
- 'number': phone.number,
- 'label': phone.label,
- });
-}
-
-/// Decodes [String] into a structured [PhoneNumberEntityData].
-PhoneNumberEntityData _decode(String data) {
- assert(data != null);
- assert(data.isNotEmpty);
-
- try {
- Map<String, String> decodedJson = json.decode(data);
- return PhoneNumberEntityData(
- number: decodedJson['number'],
- label: decodedJson['label'] ?? '',
- );
- } on Exception catch (e) {
- // since this is just a first pass, not really going to do too much
- // additional validation here but would like to know if this ever does
- // error out
- log.warning('$_kType entity error when decoding from json string: $json'
- '\nerror: $e');
- rethrow;
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/phone_number_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.contact/phone_number_entity_data.dart
deleted file mode 100644
index 07d718a..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.contact/phone_number_entity_data.dart
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-/// The Entity schema for a phone number
-class PhoneNumberEntityData {
- /// Phone number, e.g. 911, 1-408-111-2222
- final String number;
-
- /// Optional label to give for the phone entry, e.g. Cell, Home, Work...
- final String label;
-
- /// Constructor
- PhoneNumberEntityData({
- @required this.number,
- this.label,
- }) : assert(number != null && number.isNotEmpty);
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.documents/documents_id_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.documents/documents_id_codec.dart
deleted file mode 100644
index ecac792..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.documents/documents_id_codec.dart
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import '../entity_codec.dart';
-import 'documents_id_entity_data.dart';
-
-export 'documents_id_entity_data.dart';
-
-/// This [EntityCodec] translates Entity source data to and from the structured
-/// [DocumentsIdEntityData].
-class DocumentsIdEntityCodec extends EntityCodec<DocumentsIdEntityData> {
- /// Create an instance of [DocumentsIdEntityCodec].
- DocumentsIdEntityCodec()
- : super(
- type: 'com.fuchsia.documents.id',
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [DocumentsIdEntityData] into a [String].
-String _encode(DocumentsIdEntityData data) {
- if (data == null) {
- return null;
- }
- return data.id;
-}
-
-/// Decodes [String] into a structured [DocumentsIdEntityData].
-DocumentsIdEntityData _decode(String data) {
- return DocumentsIdEntityData(id: data);
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.documents/documents_id_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.documents/documents_id_entity_data.dart
deleted file mode 100644
index b8d789d..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.documents/documents_id_entity_data.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/// Holds strucutred data decoded from the document id's data.
-class DocumentsIdEntityData {
- /// A string representing this documents id or null if no document
- final String id;
-
- /// Create a new instance of [DocumentsIdEntityData].
- const DocumentsIdEntityData({
- this.id,
- });
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.intent/intent_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.intent/intent_entity_codec.dart
deleted file mode 100644
index f8169f7..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.intent/intent_entity_codec.dart
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert';
-
-import 'package:lib.app.dart/logging.dart';
-
-import '../entity_codec.dart';
-import 'intent_entity_data.dart';
-
-const String _kType = 'com.fuchsia.intent';
-
-/// This [EntityCodec] translates Entity source data to and from the structured
-/// [IntentEntityData].
-class IntentEntityCodec extends EntityCodec<IntentEntityData> {
- /// Create an instance of [IntentEntityCodec].
- IntentEntityCodec()
- : super(
- type: _kType,
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [IntentEntityData] into a [String].
-String _encode(IntentEntityData intent) {
- Map<String, dynamic> data = <String, dynamic>{'parameters': intent.parameters};
- if (intent.action != null) {
- data['action'] = intent.action;
- } else if (intent.handler != null) {
- data['handler'] = intent.handler;
- }
- return json.encode(data);
-}
-
-/// Decodes [String] into a structured [IntentEntityData].
-IntentEntityData _decode(String data) {
- assert(data != null);
- assert(data.isNotEmpty);
-
- try {
- Map<String, dynamic> decodedJson = json.decode(data);
- if (!decodedJson.containsKey('action') && !decodedJson.containsKey('handler')) {
- throw Exception('Invalid IntentEntityData: data does not contain action'
- ' or handler.');
- }
-
- IntentEntityData entity;
- if (decodedJson.containsKey('action')) {
- entity = IntentEntityData.fromAction(decodedJson['action']);
- } else {
- entity = IntentEntityData.fromHandler(decodedJson['handler']);
- }
- entity.parameters.addAll(decodedJson['parameters'].cast<String, String>());
- return entity;
- } on Exception catch (e) {
- log.warning('$_kType entity error when decoding from json string: $json'
- '\nerror: $e');
- rethrow;
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.intent/intent_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.intent/intent_entity_data.dart
deleted file mode 100644
index 0dc53c4..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.intent/intent_entity_data.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/// Holds structured data decoded from the Entity's data.
-class IntentEntityData {
- /// Create an [IntentEntityData] with a generic action.
- IntentEntityData.fromAction(this.action)
- : assert(action.isNotEmpty),
- handler = null;
-
- /// Create an [IntentEntityData] with an explicit handler.
- IntentEntityData.fromHandler(this.handler)
- : assert(handler.isNotEmpty),
- action = null;
-
- /// The action of an Intent
- final String action;
-
- /// The package name of the module
- final String handler;
-
- /// The map of parameter names and their data (JSON object)
- final Map<String, String> parameters = <String, String>{};
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.location/geolocation_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.location/geolocation_entity_codec.dart
deleted file mode 100644
index c30788d..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.location/geolocation_entity_codec.dart
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert';
-
-import 'package:lib.app.dart/logging.dart';
-
-import '../entity_codec.dart';
-import 'geolocation_entity_data.dart';
-
-export 'geolocation_entity_data.dart';
-
-/// Translates Entity source data to and from the structured
-/// [GeolocationEntityData].
-class GeolocationEntityCodec extends EntityCodec<GeolocationEntityData> {
- /// Create an instance of [GeolocationEntityCodec].
- GeolocationEntityCodec()
- : super(
- type: 'com.fuchsia.location.geolocation',
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [GeolocationEntityData] into a [String].
-String _encode(GeolocationEntityData data) {
- assert(data != null);
-
- Map<String, Object> map = <String, Object>{
- 'location': <String, double>{
- 'lat': data.lat,
- 'long': data.long,
- },
- 'accuracy': data.accuracy,
- };
-
- return json.encode(map);
-}
-
-/// Decodes [String] into a structured [GeolocationEntityCodec].
-GeolocationEntityData _decode(String data) {
- if (data == null || data.isEmpty || data == 'null') {
- throw FormatException('Entity data is null: "$data"');
- }
-
- // TODO(MS-1428): use a schema to validate decoded value.
- Map<String, dynamic> map = json.decode(data);
-
- double lat;
- double long;
- double accuracy;
-
- try {
- Map<String, double> location = map['location'].cast<String, double>();
- lat = location['lat'];
- long = location['long'];
- accuracy = map['accuracy'];
- // ignore: avoid_catches_without_on_clauses
- } catch (err, stackTrace) {
- log.warning(
- 'Exception occured during JSON destructuring: \n$err\n$stackTrace');
- throw FormatException('Invalid JSON data: "$map"');
- }
-
- return GeolocationEntityData(
- lat: lat,
- long: long,
- accuracy: accuracy,
- );
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.location/geolocation_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.location/geolocation_entity_data.dart
deleted file mode 100644
index 40683ca..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.location/geolocation_entity_data.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-/// Holds strucutred data decoded from the Entity's data.
-class GeolocationEntityData {
- /// value for the lattitude coordinate.
- final double lat;
-
- /// value for the longitude coordinate.
- final double long;
-
- /// Optional accuaracy value.
- final double accuracy;
-
- /// Create a new instance of [GeolocationEntityData].
- const GeolocationEntityData({
- @required this.lat,
- @required this.long,
- this.accuracy,
- }) : assert(lat != null),
- assert(long != null);
-
- @override
- String toString() {
- return 'GeolocationEntityData('
- 'lat: $lat'
- 'long: $long'
- 'accuracy: $accuracy'
- ')';
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.location/street_location_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.location/street_location_entity_codec.dart
deleted file mode 100644
index f34b7bb..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.location/street_location_entity_codec.dart
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert';
-
-import 'package:lib.app.dart/logging.dart';
-
-import '../entity_codec.dart';
-import 'street_location_entity_data.dart';
-
-export 'street_location_entity_data.dart';
-
-/// Translates Entity source data to and from the structured
-/// [StreetLocationEntityData].
-class StreetLocationEntityCodec extends EntityCodec<StreetLocationEntityData> {
- /// Create an instance of [StreetLocationEntityCodec].
- StreetLocationEntityCodec()
- : super(
- type: 'com.fuchsia.location.streetLocation',
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [StreetLocationEntityData] into a [String].
-String _encode(StreetLocationEntityData data) {
- assert(data != null);
-
- Map<String, Object> map = <String, Object>{
- 'location': <String, String>{
- 'streetAddress': data.streetAddress,
- 'locality': data.locality,
- },
- };
-
- return json.encode(map);
-}
-
-/// Decodes [String] into a structured [StreetLocationEntityCodec].
-StreetLocationEntityData _decode(String data) {
- if (data == null || data.isEmpty || data == 'null') {
- throw FormatException('Entity data is null: "$data"');
- }
-
- // TODO(MS-1428): use a schema to validate decoded value.
- dynamic map = json.decode(data);
-
- String streetAddress;
- String locality;
-
- try {
- dynamic location = map['location'];
- streetAddress = location['streetAddress'];
- locality = location['locality'];
- // ignore: avoid_catches_without_on_clauses
- } catch (err, stackTrace) {
- log.warning(
- 'Exception occured during JSON destructuring: \n$err\n$stackTrace');
- throw FormatException('Invalid JSON data: "$map"');
- }
-
- return StreetLocationEntityData(
- streetAddress: streetAddress,
- locality: locality,
- );
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.location/street_location_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.location/street_location_entity_data.dart
deleted file mode 100644
index 85d954b..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.location/street_location_entity_data.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-// TODO(maryxia) MS-1530 make this more granular, e.g. zip code
-/// Holds strucutred data decoded from the Entity's data.
-class StreetLocationEntityData {
- /// Street address, e.g. '123 A St'
- final String streetAddress;
-
- /// Locality, e.g. 'San Francisco'
- final String locality;
-
- /// Create a new instance of [StreetLocationEntityData].
- const StreetLocationEntityData({
- @required this.streetAddress,
- @required this.locality,
- }) : assert(streetAddress != null),
- assert(locality != null);
-
- @override
- String toString() {
- return 'StreetLocationEntityData('
- 'streetAddress: $streetAddress'
- 'locality: $locality'
- ')';
- }
-
- String toStreetAddress() {
- return '$streetAddress, $locality';
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.status/status_entity_codec.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.status/status_entity_codec.dart
deleted file mode 100644
index 1d7a49f..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.status/status_entity_codec.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import '../entity_codec.dart';
-import 'status_entity_data.dart';
-
-export 'status_entity_data.dart';
-
-/// This [EntityCodec] translates Entity source data to and from the structured
-/// [StatusEntityData].
-class StatusEntityCodec extends EntityCodec<StatusEntityData> {
- /// Create an instance of [StatusEntityCodec].
- StatusEntityCodec()
- : super(
- type: 'com.fuchsia.status',
- encode: _encode,
- decode: _decode,
- );
-}
-
-/// Encodes [StatusEntityData] into a [String].
-String _encode(StatusEntityData data) {
- assert(data != null);
-
- return data.value;
-}
-
-/// Decodes [String] into a structured [StatusEntityData].
-StatusEntityData _decode(String data) {
- assert(data != null);
- assert(data.isNotEmpty);
-
- return StatusEntityData(value: data);
-}
diff --git a/public/lib/schemas/dart/lib/src/com.fuchsia.status/status_entity_data.dart b/public/lib/schemas/dart/lib/src/com.fuchsia.status/status_entity_data.dart
deleted file mode 100644
index a53b243..0000000
--- a/public/lib/schemas/dart/lib/src/com.fuchsia.status/status_entity_data.dart
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'package:meta/meta.dart';
-
-/// Holds strucutred data decoded from the Entity's data.
-class StatusEntityData {
- /// A string value denoting status.
- final String value;
-
- /// Create a new instance of [StatusEntityData].
- const StatusEntityData({
- @required this.value,
- }) : assert(value != null);
-}
diff --git a/public/lib/schemas/dart/lib/src/entity_codec.dart b/public/lib/schemas/dart/lib/src/entity_codec.dart
deleted file mode 100644
index 8ce73cd..0000000
--- a/public/lib/schemas/dart/lib/src/entity_codec.dart
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:async';
-import 'dart:convert';
-
-import 'package:meta/meta.dart';
-
-/// When an Entity does not support a given type.
-class EntityTypeException implements Exception {
- /// The unsuported type.
- final String type;
-
- /// Create a new [EntityTypeException].
- EntityTypeException(this.type);
-
- @override
- String toString() =>
- 'EntityTypeError: type "$type" is not available for Entity';
-}
-
-/// A [Codec] used for handling the the automatic translation of to and from and
-/// Entity's source data to the specified Dart type [T].
-class EntityCodec<T> extends Codec<T, String> {
- /// The "type" this codec is associated with, similar to mime-type, see
- /// [Entity#GetTypes](https://goo.gl/QJo3tW).
- final String type;
-
- final _EntityEncoder<T> _encoder;
- final _EntityDecoder<T> _decoder;
-
- /// Create a new [EntityCodec].
- EntityCodec({
- @required this.type,
- @required _EncodeEntity<T> encode,
- @required _DecodeEntity<T> decode,
- }) : assert(type != null),
- assert(type.isEmpty == false),
- assert(encode != null),
- assert(decode != null),
- _encoder = _EntityEncoder<T>(encode),
- _decoder = _EntityDecoder<T>(decode);
-
- @override
- _EntityEncoder<T> get encoder => _encoder;
-
- @override
- _EntityDecoder<T> get decoder => _decoder;
-}
-
-typedef _EncodeEntity<T> = String Function(T value);
-
-class _EntityEncoder<T> extends Converter<T, String> {
- final _EncodeEntity<T> encode;
-
- const _EntityEncoder(this.encode);
-
- @override
- String convert(T source) {
- return encode(source);
- }
-}
-
-typedef _DecodeEntity<T> = T Function(String data);
-
-class _EntityDecoder<T> extends Converter<String, T> {
- final _DecodeEntity<T> decode;
-
- const _EntityDecoder(this.decode);
-
- @override
- T convert(String data) => decode(data);
-
- @override
- Stream<T> bind(Stream<String> source) {
- EntityDecoderSink<T> map(EventSink<T> out) =>
- EntityDecoderSink<T>(out, this);
-
- return Stream<T>.eventTransformed(source, map);
- }
-}
-
-/// Entity data [String]s in, [T] out.
-class EntityDecoderSink<T> extends EventSink<String> {
- /// The [EventSink] that values are decoded into. Errors generated by the
- /// decoder are also added to [out].
- final EventSink<T> out;
-
- /// The decoder to used to convert the source ([Stream<String>]) events.
- final _EntityDecoder<T> decoder;
-
- /// Create an instance of [EntityDecoderSink], usually via the
- /// [Stream#eventTransformed] constructor.
- EntityDecoderSink(this.out, this.decoder);
-
- @override
- void add(String data) {
- try {
- T value = decoder.decode(data);
- out.add(value);
- } on Object catch (err, stackTrace) {
- addError(err, stackTrace);
- }
- }
-
- @override
- void addError(Object e, [StackTrace s]) => out.addError(e, s);
-
- @override
- void close() => out.close();
-}
diff --git a/public/lib/schemas/dart/lib/src/parse_int.dart b/public/lib/schemas/dart/lib/src/parse_int.dart
deleted file mode 100644
index 55c17ae..0000000
--- a/public/lib/schemas/dart/lib/src/parse_int.dart
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/// Parses a value to an integer
-/// Handles cases when the value is already an integer
-int parseInt(Object value, {int onError(String source)}) {
- if (value is int) {
- return value;
- } else {
- return int.tryParse(value) ?? onError(value);
- }
-}
diff --git a/public/lib/schemas/dart/lib/src/string_list_entity_codec.dart b/public/lib/schemas/dart/lib/src/string_list_entity_codec.dart
deleted file mode 100644
index b852143..0000000
--- a/public/lib/schemas/dart/lib/src/string_list_entity_codec.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:convert' show json;
-
-import 'package:lib.app.dart/logging.dart';
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-/// Convert list of Strings to a form passable over a Link between
-/// modules.
-class StringListEntityCodec extends EntityCodec<List<String>> {
- /// Constuctor assigns the proper values to en/decode a the request.
- StringListEntityCodec(String entityType)
- : super(
- type: entityType,
- encode: _encode,
- decode: _decode,
- );
-
- static String _encode(List<String> data) {
- log.fine('Encode data to json: $data');
- if (data == null) {
- return 'null';
- }
- return json.encode(data);
- }
-
- static List<String> _decode(Object data) {
- log.fine('Convert to data from json: $data');
- if (data == null) {
- return null;
- }
- if (data is! String) {
- throw const FormatException('Decoding Entity with unsupported type');
- }
- String encoded = data;
- if (encoded.isEmpty) {
- throw const FormatException('Decoding Entity with empty string');
- }
- if (encoded == 'null') {
- return null;
- }
- dynamic decoded = json.decode(encoded);
- if (decoded == null || decoded is! List) {
- throw const FormatException('Decoding Entity with invalid data');
- }
- // Ensure the type is a List<String>, otherwise you get a List<dynamic>
- return decoded.cast<String>();
- }
-}
diff --git a/public/lib/schemas/dart/pubspec.yaml b/public/lib/schemas/dart/pubspec.yaml
deleted file mode 100644
index ba21c30..0000000
--- a/public/lib/schemas/dart/pubspec.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-name: lib.schemas.dart
diff --git a/public/lib/schemas/dart/test/entity_codec_test.dart b/public/lib/schemas/dart/test/entity_codec_test.dart
deleted file mode 100644
index a5a7444..0000000
--- a/public/lib/schemas/dart/test/entity_codec_test.dart
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:test/test.dart';
-import 'package:lib.schemas.dart/entity_codec.dart';
-
-void main() {
- group('EntityCodec<T> streaming transform', () {
- final EntityCodec<BasicExample> codec = EntityCodec<BasicExample>(
- type: 'com.example.basic',
- encode: (BasicExample value) => value.name,
- decode: (String data) => BasicExample(data),
- );
-
- test('stream.transform(codec)', () async {
- List<String> list = <String>['foo', 'bar', 'baz'];
-
- Stream<String> stream = Stream<String>.fromIterable(list);
- List<String> results = await stream
- .transform(codec.decoder)
- .map((BasicExample e) => e.name)
- .toList();
-
- expect(results.length, equals(list.length));
- });
- });
-}
-
-class BasicExample {
- final String name;
-
- BasicExample(this.name);
-}