Skip to content

Commit

Permalink
fixup! feat!: rework library structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 5, 2024
1 parent 970ed35 commit 2beed50
Show file tree
Hide file tree
Showing 80 changed files with 324 additions and 366 deletions.
3 changes: 1 addition & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ include: package:lint/analysis_options_package.yaml
# Adjusted linting rules
linter:
rules:
always_use_package_imports: false
prefer_relative_imports: true
always_use_package_imports: true
prefer_double_quotes: true
sort_constructors_first: true
unawaited_futures: true
Expand Down
22 changes: 11 additions & 11 deletions lib/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export "package:dcaf/dcaf.dart";

export "src/core/augmented_form.dart";
export "src/core/codecs/content_codec.dart";
export "src/core/content.dart";
export "src/core/content_serdes.dart";

export "src/core/credentials/ace_credentials.dart";
export "src/core/credentials/apikey_credentials.dart";
export "src/core/credentials/basic_credentials.dart";
Expand All @@ -24,7 +26,12 @@ export "src/core/credentials/digest_credentials.dart";
export "src/core/credentials/oauth2_credentials.dart";
export "src/core/credentials/psk_credentials.dart";

export "src/core/definitions/additional_expected_response.dart";
export "src/core/definitions/data_schema.dart";
export "src/core/definitions/expected_response.dart";
export "src/core/definitions/form.dart";
export "src/core/definitions/interaction_affordances/interaction_affordance.dart";
export "src/core/definitions/operation_type.dart";

export "src/core/definitions/security/ace_security_scheme.dart";
export "src/core/definitions/security/apikey_security_scheme.dart";
Expand All @@ -42,20 +49,13 @@ export "src/core/definitions/thing_model.dart";
export "src/core/definitions/validation/thing_description_schema.dart"
show thingDescriptionSchema;

export "src/core/definitions/validation/validation_exception.dart";
export "src/core/discovery_expection.dart";

export "src/core/protocol_interfaces/protocol_client.dart";
export "src/core/protocol_interfaces/protocol_client_factory.dart";
export "src/core/protocol_interfaces/protocol_server.dart";

export "src/core/scripting_api/consumed_thing.dart";
export "src/core/scripting_api/data_schema_value.dart";
export "src/core/scripting_api/discovery/discovery_method.dart";
export "src/core/scripting_api/discovery/thing_discovery.dart";
export "src/core/scripting_api/discovery/thing_filter.dart";
export "src/core/scripting_api/exposed_thing.dart";
export "src/core/scripting_api/interaction_input.dart";
export "src/core/scripting_api/interaction_output.dart";
export "src/core/scripting_api/subscription.dart";
export "src/core/scripting_api/types.dart";
export "src/core/scripting_api/wot.dart";
export "src/core/scripting_api.dart";

export "src/core/servient.dart";
23 changes: 8 additions & 15 deletions lib/src/binding_coap/coap_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ import "dart:typed_data";

import "package:coap/coap.dart" as coap;
import "package:coap/config/coap_config_default.dart";
import "package:dcaf/dcaf.dart";

import "../core/augmented_form.dart";
import "../core/content.dart";
import "../core/credentials/ace_credentials.dart";
import "../core/credentials/callbacks.dart";
import "../core/credentials/psk_credentials.dart";
import "../core/definitions/operation_type.dart";
import "../core/protocol_interfaces/protocol_client.dart";
import "../core/scripting_api/subscription.dart";
import "coap_binding_exception.dart";
import "coap_config.dart";
import "coap_definitions.dart";
import "coap_extensions.dart";
import "coap_subscription.dart";

import "package:dart_wot/core.dart";

import "package:dart_wot/src/binding_coap/coap_binding_exception.dart";
import "package:dart_wot/src/binding_coap/coap_config.dart";
import "package:dart_wot/src/binding_coap/coap_definitions.dart";
import "package:dart_wot/src/binding_coap/coap_extensions.dart";
import "package:dart_wot/src/binding_coap/coap_subscription.dart";

class _InternalCoapConfig extends CoapConfigDefault {
_InternalCoapConfig(CoapConfig coapConfig)
Expand Down
9 changes: 4 additions & 5 deletions lib/src/binding_coap/coap_client_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
//
// SPDX-License-Identifier: BSD-3-Clause

import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_client.dart";
import "../core/protocol_interfaces/protocol_client_factory.dart";
import "coap_client.dart";
import "coap_config.dart";
import "package:dart_wot/core.dart";

import "package:dart_wot/src/binding_coap/coap_client.dart";
import "package:dart_wot/src/binding_coap/coap_config.dart";

/// A [ProtocolClientFactory] that produces CoAP clients.
final class CoapClientFactory implements ProtocolClientFactory {
Expand Down
22 changes: 12 additions & 10 deletions lib/src/binding_coap/coap_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import "dart:typed_data";

import "package:cbor/cbor.dart";
import "package:coap/coap.dart";

import "package:dart_wot/core.dart" hide PskCredentials;
import "package:dart_wot/src/binding_coap/coap_binding_exception.dart";
import "package:dart_wot/src/binding_coap/coap_definitions.dart";
import "package:dart_wot/src/core/augmented_form.dart";
import "package:dart_wot/src/core/content.dart";
import "package:dart_wot/src/core/definitions/expected_response.dart";
import "package:dart_wot/src/core/definitions/operation_type.dart";
import "package:dart_wot/src/core/definitions/security/ace_security_scheme.dart";
import "package:dart_wot/src/core/definitions/security/auto_security_scheme.dart";
import "package:dart_wot/src/core/definitions/security/psk_security_scheme.dart";
import "package:dart_wot/src/core/definitions/validation/validation_exception.dart";

import "coap_binding_exception.dart";
import "coap_definitions.dart";
import "package:dcaf/dcaf.dart";

/// Extension which makes it easier to handle [Uri]s containing
/// [InternetAddress]es.
Expand All @@ -22,7 +24,7 @@ extension InternetAddressMethods on Uri {
}
}

/// CoAP-specific extensions for the [Form] class.
/// CoAP-specific extensions for the [AugmentedForm] class.
extension CoapFormExtension on AugmentedForm {
T? _obtainVocabularyTerm<T>(String vocabularyTerm) {
final curieString = coapPrefixMapping.expandCurieString(vocabularyTerm);
Expand All @@ -35,15 +37,15 @@ extension CoapFormExtension on AugmentedForm {
return null;
}

/// Determines if this [Form] supports the [PskSecurityScheme].
/// Determines if this [AugmentedForm] supports the [PskSecurityScheme].
bool get usesPskScheme =>
securityDefinitions.whereType<PskSecurityScheme>().isNotEmpty;

/// Determines if this [Form] supports the [AutoSecurityScheme].
/// Determines if this [AugmentedForm] supports the [AutoSecurityScheme].
bool get usesAutoScheme =>
securityDefinitions.whereType<AutoSecurityScheme>().isNotEmpty;

/// Get the [CoapSubprotocol] for this [Form], if one is set.
/// Get the [CoapSubprotocol] for this [AugmentedForm], if one is set.
CoapSubprotocol? get coapSubprotocol {
if (subprotocol == coapPrefixMapping.expandCurieString("observe")) {
return CoapSubprotocol.observe;
Expand Down Expand Up @@ -103,7 +105,7 @@ extension CoapFormExtension on AugmentedForm {
BlockSize? get block1Size => _determineBlockSize("block1Size");

// TODO: Consider default method
/// Indicates the [CoapRequestMethod] contained in this [Form].
/// Indicates the [CoapRequestMethod] contained in this [AugmentedForm].
CoapRequestMethod? get method {
final methodDefinition = _obtainVocabularyTerm<String>("method");

Expand Down
8 changes: 4 additions & 4 deletions lib/src/binding_coap/coap_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//
// SPDX-License-Identifier: BSD-3-Clause

import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_server.dart";
import '../core/scripting_api/exposed_thing.dart';
import "coap_config.dart";
import "package:dart_wot/src/binding_coap/coap_config.dart";
import "package:dart_wot/src/core/credentials/callbacks.dart";
import "package:dart_wot/src/core/protocol_interfaces/protocol_server.dart";
import "package:dart_wot/src/core/scripting_api/exposed_thing.dart";

/// A [ProtocolServer] for the Constrained Application Protocol (CoAP).
final class CoapServer implements ProtocolServer {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/binding_coap/coap_subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import "package:coap/coap.dart";

import '../core/scripting_api/subscription.dart';
import "package:dart_wot/src/core/scripting_api/subscription.dart";

/// [Subscription] to a CoAP resource, based on the observe option ([RFC 7641]).
///
Expand Down
9 changes: 4 additions & 5 deletions lib/src/binding_http/http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import "dart:convert";
import "dart:io";

import "package:dart_wot/core.dart";
import "package:dart_wot/src/core/definitions/operation_type.dart";
import "package:http/http.dart";

import "../core/content.dart";
import "http_request_method.dart";
import "http_security_exception.dart";
import "package:dart_wot/src/binding_http/http_request_method.dart";
import "package:dart_wot/src/binding_http/http_security_exception.dart";

import "package:http/http.dart";

const _authorizationHeader = "Authorization";

Expand Down
14 changes: 7 additions & 7 deletions lib/src/binding_http/http_client_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
//
// SPDX-License-Identifier: BSD-3-Clause

import "../core/credentials/basic_credentials.dart";
import "../core/credentials/bearer_credentials.dart";
import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_client.dart";
import "../core/protocol_interfaces/protocol_client_factory.dart";
import "http_client.dart";
import "http_config.dart";
import "package:dart_wot/src/binding_http/http_client.dart";
import "package:dart_wot/src/binding_http/http_config.dart";
import "package:dart_wot/src/core/credentials/basic_credentials.dart";
import "package:dart_wot/src/core/credentials/bearer_credentials.dart";
import "package:dart_wot/src/core/credentials/callbacks.dart";
import "package:dart_wot/src/core/protocol_interfaces/protocol_client.dart";
import "package:dart_wot/src/core/protocol_interfaces/protocol_client_factory.dart";

/// A [ProtocolClientFactory] that produces HTTP and HTTPS clients.
final class HttpClientFactory implements ProtocolClientFactory {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/binding_http/http_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
//
// SPDX-License-Identifier: BSD-3-Clause

import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_server.dart";
import "../core/scripting_api/exposed_thing.dart";
import "http_config.dart";
import "package:dart_wot/src/binding_http/http_config.dart";
import "package:dart_wot/src/core/credentials/callbacks.dart";
import "package:dart_wot/src/core/protocol_interfaces/protocol_server.dart";
import "package:dart_wot/src/core/scripting_api/exposed_thing.dart";

/// A [ProtocolServer] for the Hypertext Transfer Protocol (HTTP).
final class HttpServer implements ProtocolServer {
Expand Down
23 changes: 11 additions & 12 deletions lib/src/binding_mqtt/mqtt_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@

import "dart:async";

import "package:dart_wot/src/binding_mqtt/constants.dart";
import "package:dart_wot/src/binding_mqtt/mqtt_binding_exception.dart";
import "package:dart_wot/src/binding_mqtt/mqtt_config.dart";
import "package:dart_wot/src/binding_mqtt/mqtt_extensions.dart";
import "package:dart_wot/src/binding_mqtt/mqtt_subscription.dart";
import "package:dart_wot/src/core/augmented_form.dart";
import "package:dart_wot/src/core/content.dart";
import "package:dart_wot/src/core/credentials/basic_credentials.dart";
import "package:dart_wot/src/core/credentials/callbacks.dart";
import "package:dart_wot/src/core/protocol_interfaces/protocol_client.dart";
import "package:dart_wot/src/core/scripting_api/subscription.dart" as scripting_api;
import "package:mqtt_client/mqtt_client.dart";
import "package:mqtt_client/mqtt_server_client.dart";
import "package:typed_data/typed_buffers.dart";

import "../core/augmented_form.dart";
import "../core/content.dart";
import "../core/credentials/basic_credentials.dart";
import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_client.dart";
import "../core/scripting_api/subscription.dart" as scripting_api;
import "constants.dart";
import "mqtt_binding_exception.dart";
import "mqtt_config.dart";
import "mqtt_extensions.dart";
import "mqtt_subscription.dart";

/// [ProtocolClient] for supporting the MQTT protocol.
///
/// Currently, only MQTT version 3.1.1 is supported.
Expand Down
14 changes: 7 additions & 7 deletions lib/src/binding_mqtt/mqtt_client_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
//
// SPDX-License-Identifier: BSD-3-Clause

import "../core/credentials/basic_credentials.dart";
import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_client.dart";
import "../core/protocol_interfaces/protocol_client_factory.dart";
import "constants.dart";
import "mqtt_client.dart";
import "mqtt_config.dart";
import "package:dart_wot/src/binding_mqtt/constants.dart";
import "package:dart_wot/src/binding_mqtt/mqtt_client.dart";
import "package:dart_wot/src/binding_mqtt/mqtt_config.dart";
import "package:dart_wot/src/core/credentials/basic_credentials.dart";
import "package:dart_wot/src/core/credentials/callbacks.dart";
import "package:dart_wot/src/core/protocol_interfaces/protocol_client.dart";
import "package:dart_wot/src/core/protocol_interfaces/protocol_client_factory.dart";

/// [ProtocolClientFactory] for creating [MqttClient]s.
final class MqttClientFactory implements ProtocolClientFactory {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/binding_mqtt/mqtt_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
//
// SPDX-License-Identifier: BSD-3-Clause

import "package:dart_wot/src/binding_mqtt/constants.dart";
import "package:meta/meta.dart";
import "package:mqtt_client/mqtt_client.dart";

import "constants.dart";

/// Allows for configuring the behavior of MQTT clients and servers.
///
/// The default [QoS] values for the different operation types will be used if
Expand Down
11 changes: 5 additions & 6 deletions lib/src/binding_mqtt/mqtt_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
// SPDX-License-Identifier: BSD-3-Clause

import "package:curie/curie.dart";
import "package:dart_wot/src/core/definitions/validation/validation_exception.dart";

import "package:dart_wot/core.dart";
import "package:dart_wot/src/binding_mqtt/constants.dart";
import "package:dart_wot/src/binding_mqtt/mqtt_binding_exception.dart";

import "package:mqtt_client/mqtt_client.dart";
import "package:mqtt_client/mqtt_server_client.dart";
import "package:uuid/uuid.dart";

import "../../core.dart";

import "constants.dart";
import "mqtt_binding_exception.dart";

/// [PrefixMapping] for expanding MQTT Vocabulary terms from compact IRIs.
final mqttPrefixMapping = PrefixMapping(defaultPrefixValue: mqttContextUri);

Expand Down
5 changes: 2 additions & 3 deletions lib/src/binding_mqtt/mqtt_subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
// SPDX-License-Identifier: BSD-3-Clause

import "package:dart_wot/core.dart";
import "package:dart_wot/src/core/scripting_api/subscription.dart"
as scripting_api;
import "package:mqtt_client/mqtt_client.dart";
import "package:mqtt_client/mqtt_server_client.dart";

import "../core/content.dart";
import "../core/scripting_api/subscription.dart" as scripting_api;

/// [scripting_api.Subscription] for the MQTT protocol.
class MqttSubscription implements scripting_api.Subscription {
/// Constructor.
Expand Down
17 changes: 8 additions & 9 deletions lib/src/core/augmented_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
// SPDX-License-Identifier: BSD-3-Clause

import "package:collection/collection.dart";
import "package:dart_wot/src/core/definitions/additional_expected_response.dart";
import "package:dart_wot/src/core/definitions/expected_response.dart";
import "package:dart_wot/src/core/definitions/form.dart";
import "package:dart_wot/src/core/definitions/interaction_affordances/interaction_affordance.dart";
import "package:dart_wot/src/core/definitions/operation_type.dart";
import "package:dart_wot/src/core/definitions/security/security_scheme.dart";
import "package:dart_wot/src/core/definitions/thing_description.dart";
import "package:dart_wot/src/core/definitions/validation/validation_exception.dart";
import "package:json_schema/json_schema.dart";
import "package:meta/meta.dart";
import "package:uri/uri.dart";

import "definitions/additional_expected_response.dart";
import "definitions/expected_response.dart";
import "definitions/form.dart";
import "definitions/interaction_affordances/interaction_affordance.dart";
import "definitions/operation_type.dart";
import "definitions/security/security_scheme.dart";
import "definitions/thing_description.dart";
import "definitions/validation/validation_exception.dart";

/// A [Form] augmented with information from its asscociated [_thingDescription]
/// and [_interactionAffordance].
@immutable
Expand Down
7 changes: 3 additions & 4 deletions lib/src/core/codecs/cbor_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
// SPDX-License-Identifier: BSD-3-Clause

import "package:cbor/cbor.dart" as cbor;

import "../definitions/data_schema.dart";
import "../scripting_api/data_schema_value.dart";
import "content_codec.dart";
import "package:dart_wot/src/core/codecs/content_codec.dart";
import "package:dart_wot/src/core/definitions/data_schema.dart";
import "package:dart_wot/src/core/scripting_api/data_schema_value.dart";

/// A [ContentCodec] that encodes and decodes CBOR data.
class CborCodec extends ContentCodec {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/codecs/content_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// SPDX-License-Identifier: BSD-3-Clause

import "../definitions/data_schema.dart";
import "../scripting_api/data_schema_value.dart";
import "package:dart_wot/src/core/definitions/data_schema.dart";
import "package:dart_wot/src/core/scripting_api/data_schema_value.dart";

/// Interface for providing a codec for a specific media type.
abstract class ContentCodec {
Expand Down
Loading

0 comments on commit 2beed50

Please sign in to comment.