Skip to content

Commit

Permalink
feat!: rework library structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 4, 2024
1 parent a6396c2 commit 970ed35
Show file tree
Hide file tree
Showing 103 changed files with 541 additions and 314 deletions.
3 changes: 2 additions & 1 deletion example/coap_discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

// ignore_for_file: avoid_print

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_coap.dart";
import "package:dart_wot/core.dart";

const propertyName = "string";

Expand Down
3 changes: 2 additions & 1 deletion example/coap_dns_sd_discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

// ignore_for_file: avoid_print

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_coap.dart";
import "package:dart_wot/core.dart";

void handleThingDescription(ThingDescription thingDescription) =>
print('Discovered TD with title "${thingDescription.title}".');
Expand Down
3 changes: 2 additions & 1 deletion example/coaps_readproperty.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import "dart:typed_data";

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_coap.dart";
import "package:dart_wot/core.dart";

/// Matches [PskCredentials] by hostname and URI scheme.
final Map<Uri, PskCredentials> _pskCredentialsStore = {
Expand Down
4 changes: 3 additions & 1 deletion example/complex_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

// ignore_for_file: avoid_print

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_coap.dart";
import "package:dart_wot/binding_http.dart";
import "package:dart_wot/core.dart";

const thingDescriptionJson = {
"@context": [
Expand Down
3 changes: 2 additions & 1 deletion example/core_link_format_discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

// ignore_for_file: avoid_print

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_coap.dart";
import "package:dart_wot/core.dart";

Future<void> main(List<String> args) async {
final servient = Servient(clientFactories: [CoapClientFactory()]);
Expand Down
3 changes: 2 additions & 1 deletion example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

// ignore_for_file: avoid_print

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_coap.dart";
import "package:dart_wot/core.dart";

Future<void> main(List<String> args) async {
final servient = Servient(
Expand Down
3 changes: 2 additions & 1 deletion example/http_basic_authentication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

// ignore_for_file: avoid_print

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_http.dart";
import "package:dart_wot/core.dart";

const username = "username";
const password = "password";
Expand Down
3 changes: 2 additions & 1 deletion example/mqtt_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

// ignore_for_file: avoid_print

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/binding_mqtt.dart";
import "package:dart_wot/core.dart";

const thingDescriptionJson = {
"@context": "https://www.w3.org/2022/wot/td/v1.1",
Expand Down
32 changes: 32 additions & 0 deletions lib/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,39 @@ export "src/core/credentials/credentials.dart";
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/form.dart";

export "src/core/definitions/security/ace_security_scheme.dart";
export "src/core/definitions/security/apikey_security_scheme.dart";
export "src/core/definitions/security/auto_security_scheme.dart";
export "src/core/definitions/security/basic_security_scheme.dart";
export "src/core/definitions/security/bearer_security_scheme.dart";
export "src/core/definitions/security/combo_security_scheme.dart";
export "src/core/definitions/security/digest_security_scheme.dart";
export "src/core/definitions/security/no_security_scheme.dart";
export "src/core/definitions/security/oauth2_security_scheme.dart";
export "src/core/definitions/security/psk_security_scheme.dart";

export "src/core/definitions/thing_description.dart";
export "src/core/definitions/thing_model.dart";
export "src/core/definitions/validation/thing_description_schema.dart"
show thingDescriptionSchema;

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/servient.dart";
15 changes: 0 additions & 15 deletions lib/dart_wot.dart

This file was deleted.

17 changes: 0 additions & 17 deletions lib/definitions.dart

This file was deleted.

23 changes: 0 additions & 23 deletions lib/scripting_api.dart

This file was deleted.

7 changes: 3 additions & 4 deletions lib/src/binding_coap/coap_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ 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 "../definitions/form.dart";
import "../definitions/operation_type.dart";
import "../scripting_api/subscription.dart";
import "../core/scripting_api/subscription.dart";
import "coap_binding_exception.dart";
import "coap_config.dart";
import "coap_definitions.dart";
Expand Down Expand Up @@ -256,7 +255,7 @@ final class CoapClient implements ProtocolClient {
}

/// Obtains an ACE creation hint serialized as a [List] of [int] from a
/// [Form].
/// [form].
///
/// Returns `null` if no `ACESecurityScheme` is defined.
Future<AuthServerRequestCreationHint?> _obtainAceCreationHintFromForm(
Expand Down
18 changes: 7 additions & 11 deletions lib/src/binding_coap/coap_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ import "dart:typed_data";

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

import "../core/augmented_form.dart";
import "../core/content.dart";
import "../definitions/expected_response.dart";
import "../definitions/form.dart";
import "../definitions/operation_type.dart";
import "../definitions/security/ace_security_scheme.dart";
import "../definitions/security/auto_security_scheme.dart";
import "../definitions/security/psk_security_scheme.dart";
import "../definitions/validation/validation_exception.dart";

import "package:dart_wot/core.dart" hide PskCredentials;
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/validation/validation_exception.dart";

import "coap_binding_exception.dart";
import "coap_definitions.dart";

Expand Down
2 changes: 1 addition & 1 deletion lib/src/binding_coap/coap_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_server.dart";
import "../scripting_api/exposed_thing.dart";
import '../core/scripting_api/exposed_thing.dart';
import "coap_config.dart";

/// A [ProtocolServer] for the Constrained Application Protocol (CoAP).
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 "../scripting_api/subscription.dart";
import '../core/scripting_api/subscription.dart';

/// [Subscription] to a CoAP resource, based on the observe option ([RFC 7641]).
///
Expand Down
12 changes: 2 additions & 10 deletions lib/src/binding_http/http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,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/augmented_form.dart";
import "../core/content.dart";
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 "../definitions/form.dart";
import "../definitions/operation_type.dart";
import "../definitions/security/basic_security_scheme.dart";
import "../definitions/security/bearer_security_scheme.dart";
import "../scripting_api/subscription.dart";
import "http_request_method.dart";
import "http_security_exception.dart";

Expand Down
4 changes: 2 additions & 2 deletions lib/src/binding_http/http_request_method.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "../definitions/form.dart";
import "../definitions/operation_type.dart";
import "package:dart_wot/src/core/definitions/form.dart";
import "package:dart_wot/src/core/definitions/operation_type.dart";

const _getString = "GET";
const _putString = "PUT";
Expand Down
2 changes: 1 addition & 1 deletion lib/src/binding_http/http_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_server.dart";
import "../scripting_api/exposed_thing.dart";
import "../core/scripting_api/exposed_thing.dart";
import "http_config.dart";

/// A [ProtocolServer] for the Hypertext Transfer Protocol (HTTP).
Expand Down
2 changes: 1 addition & 1 deletion lib/src/binding_mqtt/mqtt_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "../core/content.dart";
import "../core/credentials/basic_credentials.dart";
import "../core/credentials/callbacks.dart";
import "../core/protocol_interfaces/protocol_client.dart";
import "../scripting_api/subscription.dart" as scripting_api;
import "../core/scripting_api/subscription.dart" as scripting_api;
import "constants.dart";
import "mqtt_binding_exception.dart";
import "mqtt_config.dart";
Expand Down
9 changes: 3 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,13 @@
// SPDX-License-Identifier: BSD-3-Clause

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

import "../core/augmented_form.dart";
import "../core/credentials/basic_credentials.dart";
import "../definitions/form.dart";
import "../definitions/security/auto_security_scheme.dart";
import "../definitions/security/basic_security_scheme.dart";
import "../definitions/validation/validation_exception.dart";
import "../../core.dart";

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

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

import "package:dart_wot/core.dart";
import "package:mqtt_client/mqtt_client.dart";
import "package:mqtt_client/mqtt_server_client.dart";

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

/// [scripting_api.Subscription] for the MQTT protocol.
class MqttSubscription implements scripting_api.Subscription {
Expand Down
16 changes: 8 additions & 8 deletions lib/src/core/augmented_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ 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";
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].
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/codecs/cbor_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

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

import "../../definitions/data_schema.dart";
import "../../scripting_api/data_schema_value.dart";
import "../definitions/data_schema.dart";
import "../scripting_api/data_schema_value.dart";
import "content_codec.dart";

/// A [ContentCodec] that encodes and decodes CBOR data.
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 "../definitions/data_schema.dart";
import "../scripting_api/data_schema_value.dart";

/// Interface for providing a codec for a specific media type.
abstract class ContentCodec {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/codecs/json_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import "dart:convert";

import "../../definitions/data_schema.dart";
import "../definitions/data_schema.dart";

import "../../scripting_api/data_schema_value.dart";
import "../scripting_api/data_schema_value.dart";
import "content_codec.dart";

/// A [ContentCodec] that encodes and decodes JSON data.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/codecs/text_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import "dart:convert";

import "../../definitions/data_schema.dart";
import "../definitions/data_schema.dart";

import "../../scripting_api/data_schema_value.dart";
import "../scripting_api/data_schema_value.dart";
import "content_codec.dart";

const _utf8Coding = "utf-8";
Expand Down
Loading

0 comments on commit 970ed35

Please sign in to comment.