Spine Dart Client Library

Dart-based client for Spine applications. A facade for sending domain commands and querying entity states.

The package provides the following:

  • Dart client library;
  • generated Protobuf Dart types:
    • standard types (google.protobuf and google.protobuf.plugin);
    • required Spine types (from base, time, core, client, web, and firebase-web).

The package does not include Protobuf sources or descriptor sets. Refer to respective Maven artifacts for those.

Usage

Prerequisites

Users of this library are required to use the Spine Protobuf Dart plugin.

In order to compile Protobuf into Dart, one needs to:

  1. Activate the protoc_plugin Pub package: pub activate global protoc_plugin.
  2. Apply the Proto Dart plugin:
    buildscript {
        classpath "io.spine.tools:spine-proto-dart-plugin:$spineVersion"
    }
    
    apply plugin: 'io.spine.tools.proto-dart-plugin'
    

The Protoc plugin generates .pb.dart files. Spine Proto Dart plugin configures the Protoc plugin. By default, the .pb.dart files are generated under lib for the main scope and under test for the test scope.

Also Spine Proto Dart plugin generates types.dart — a type registry file. The type registry serves for reflection needs of the spine_client package.

Example

The example beneath demonstrates how to perform a simple query and post a bunch of commands using the client library.

// Import `spine_client` and helper libraries.
import 'package:spine_client/spine_client.dart';
import 'package:spine_client/web_firebase_client.dart';
import 'package:spine_client/time.dart';

// Import the Firebase client library.
import 'package:firebase/firebase.dart' as fb;

// Import your model types, generated from Protobuf.
import 'example/acme/task/commands.pb.dart';
import 'example/acme/task/view.pb.dart';

// Import the type registry which contains all your model types.
// Generated by Spine Proto Dart Gradle plugin.
import 'types.dart' as exampleTypes;

void main() {
    var actorId = UserId()
            ..value = '$myUserId';
    var requests = ActorRequestFactory(actorId);
    var firebase = RestClient(
            fb.Database.getInstance(myFirebaseDbJsObject()),
            'https://example-org-42.firebaseio.com'
    );
    var client = BackendClient('https://example.org',
                               firebase,
                               typeRegistries: [myTypes.types()]);
    // Fetch all `TaskView` projections and mark all tasks as done.
    client.fetch(requests.query().all(TaskView()))
          .forEach((taskView) {
              var markDone = MarkTaskDone()
                      ..id = taskView.id
                      ..who_completed = actorId;
              client.post(requests.command().create(markDone));
          });
}

Libraries

ack.pb
ack.pbenum
ack.pbjson
ack.pbserver
actor_context.pb
actor_context.pbenum
actor_context.pbjson
actor_context.pbserver
actor_request_factory
aggregate.pb
aggregate.pbenum
aggregate.pbjson
aggregate.pbserver
any.pb
any.pbenum
any.pbjson
any.pbserver
api.pb
api.pbenum
api.pbjson
api.pbserver
backend_client
bounded_context.pb
bounded_context.pbenum
bounded_context.pbjson
bounded_context.pbserver
broker.pb
broker.pbenum
broker.pbjson
broker.pbserver
change.pb
change.pbenum
change.pbjson
change.pbserver
client.pb
client.pb
client.pbenum
client.pbenum
client.pbjson
client.pbjson
client.pbserver
client.pbserver
color.pb
color.pbenum
color.pbjson
color.pbserver
command.pb
command.pbenum
command.pbjson
command.pbserver
command_factory
command_log.pb
command_log.pbenum
command_log.pbjson
command_log.pbserver
command_log_events.pb
command_log_events.pbenum
command_log_events.pbjson
command_log_events.pbserver
command_service.pb
command_service.pbenum
command_service.pbjson
command_service.pbserver
delivery.pb
delivery.pbenum
delivery.pbjson
delivery.pbserver
descriptor.pb
descriptor.pbenum
descriptor.pbjson
descriptor.pbserver
diagnostic_events.pb
diagnostic_events.pbenum
diagnostic_events.pbjson
diagnostic_events.pbserver
diagnostics.pb
diagnostics.pbenum
diagnostics.pbjson
diagnostics.pbserver
diff.pb
diff.pbenum
diff.pbjson
diff.pbserver
dispatching.pb
dispatching.pbenum
dispatching.pbjson
dispatching.pbserver
duration.pb
duration.pbenum
duration.pbjson
duration.pbserver
email_address.pb
email_address.pbenum
email_address.pbjson
email_address.pbserver
empty.pb
empty.pbenum
empty.pbjson
empty.pbserver
enrichment.pb
enrichment.pbenum
enrichment.pbjson
enrichment.pbserver
entities.pb
entities.pbenum
entities.pbjson
entities.pbserver
entity.pb
entity.pbenum
entity.pbjson
entity.pbserver
entity_log_events.pb
entity_log_events.pbenum
entity_log_events.pbjson
entity_log_events.pbserver
entity_type.pb
entity_type.pbenum
entity_type.pbjson
entity_type.pbserver
error.pb
error.pbenum
error.pbjson
error.pbserver
event.pb
event.pbenum
event.pbjson
event.pbserver
event_filter.pb
event_filter.pbenum
event_filter.pbjson
event_filter.pbserver
event_lifecycle_events.pb
event_lifecycle_events.pbenum
event_lifecycle_events.pbjson
event_lifecycle_events.pbserver
event_stream_query.pb
event_stream_query.pbenum
event_stream_query.pbjson
event_stream_query.pbserver
events.pb
events.pbenum
events.pbjson
events.pbserver
field_filter.pb
field_filter.pbenum
field_filter.pbjson
field_filter.pbserver
field_mask.pb
field_mask.pbenum
field_mask.pbjson
field_mask.pbserver
field_path.pb
field_path.pbenum
field_path.pbjson
field_path.pbserver
filters.pb
filters.pbenum
filters.pbjson
filters.pbserver
firebase_client
firebase_subscription.pb
firebase_subscription.pbenum
firebase_subscription.pbjson
firebase_subscription.pbserver
inbox.pb
inbox.pbenum
inbox.pbjson
inbox.pbserver
internet_domain.pb
internet_domain.pbenum
internet_domain.pbjson
internet_domain.pbserver
language.pb
language.pbenum
language.pbjson
language.pbserver
mirror.pb
mirror.pbenum
mirror.pbjson
mirror.pbserver
options.pb
options.pbenum
options.pbjson
options.pbserver
person_name.pb
person_name.pbenum
person_name.pbjson
person_name.pbserver
plugin.pb
plugin.pbenum
plugin.pbjson
plugin.pbserver
query.pb
query.pbenum
query.pbjson
query.pbserver
query_factory
query_service.pb
query_service.pbenum
query_service.pbjson
query_service.pbserver
response.pb
response.pb
response.pbenum
response.pbenum
response.pbjson
response.pbjson
response.pbserver
response.pbserver
rest_firebase_client
scheduled_command.pb
scheduled_command.pbenum
scheduled_command.pbjson
scheduled_command.pbserver
server_environment.pb
server_environment.pbenum
server_environment.pbjson
server_environment.pbserver
source_context.pb
source_context.pbenum
source_context.pbjson
source_context.pbserver
spine_client
The entry point for a Spine client. [...]
standard_events.pb
standard_events.pbenum
standard_events.pbjson
standard_events.pbserver
standard_rejections.pb
standard_rejections.pbenum
standard_rejections.pbjson
standard_rejections.pbserver
struct.pb
struct.pbenum
struct.pbjson
struct.pbserver
subscription.pb
subscription.pbenum
subscription.pbjson
subscription.pbserver
subscription_service.pb
subscription_service.pbenum
subscription_service.pbjson
subscription_service.pbserver
tenant.pb
tenant.pbenum
tenant.pbjson
tenant.pbserver
tenant_id.pb
tenant_id.pbenum
tenant_id.pbjson
tenant_id.pbserver
time
time.pb
time.pbenum
time.pbjson
time.pbserver
time_change.pb
time_change.pbenum
time_change.pbjson
time_change.pbserver
time_options.pb
time_options.pbenum
time_options.pbjson
time_options.pbserver
timestamp.pb
timestamp.pbenum
timestamp.pbjson
timestamp.pbserver
transport.pb
transport.pbenum
transport.pbjson
transport.pbserver
type.pb
type.pbenum
type.pbjson
type.pbserver
types
url.pb
url.pbenum
url.pbjson
url.pbserver
user_id.pb
user_id.pbenum
user_id.pbjson
user_id.pbserver
uuids
validation_error.pb
validation_error.pbenum
validation_error.pbjson
validation_error.pbserver
value_mismatch.pb
value_mismatch.pbenum
value_mismatch.pbjson
value_mismatch.pbserver
version.pb
version.pbenum
version.pbjson
version.pbserver
web_firebase_client
wrappers.pb
wrappers.pbenum
wrappers.pbjson
wrappers.pbserver