kuzzle 1.0.0-alpha.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 49

Awesome Flutter Pub codecov Build Status

Kuzzle Dart SDK #

About Kuzzle #

A backend software, self-hostable and ready to use to power modern apps.

You can access the Kuzzle repository on Github or view official website kuzzle.io.

Installation #

Include this in your pubspec.yaml

dependencies:
  kuzzle: ^1.0.0-alpha.4

Basic usage #

import 'package:kuzzle/kuzzle.dart';

final kuzzle = Kuzzle(
  WebSocketProtocol('127.0.0.1.xip.io'),
  offlineMode: OfflineMode.auto,
);

void main () async {
  // note that we don't need to await connection to be effective
  kuzzle.connect(); 
  
  final result = await kuzzle.server.info();
  print('[result][server][info] $result');
}

only WebSocketProtocol protocol is available for now, feel free to suggest a PR for other protocols submissions

Documentation and Samples #

Contributions #

If you find a bug or want a feature, but don't know how to fix/implement it, feel free to open an issue. If you fixed a bug or implemented a new feature, we will enjoy to merge your pull request.

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/example.dart

import 'package:kuzzle/kuzzle.dart';

void main() {
  final kuzzle = Kuzzle(
    WebSocketProtocol('127.0.0.1.xip.io'),
    offlineMode: OfflineMode.auto,
  );

  // connection events
  kuzzle.on('connected', () => print('[connected]'));
  kuzzle.on('disconnected', () => print('[disconnected]'));
  kuzzle.on('reconnected', () => print('[reconnected]'));

  // errors events
  kuzzle.on('discarded', (request) => print('[discarded] => $request'));
  kuzzle.on('queryError', (error, request) {
    print('[queryError] => $request');
    print(error);
  });
  kuzzle.on('networkError', (error) {
    print('[networkError]');
    print(error);
  });

  // login
  kuzzle.on('loginAttempt', ({success, error}) {
    print('[loginAttempt] success: $success');
    print(error);
  });

  // offline queue events
  kuzzle.on('offlineQueuePush', (request) => print('[queue] => $request'));
  kuzzle.on('offlineQueuePop', (request) => print('[dequeue] => $request'));

  // perform a query when offline
  kuzzle
      .query(KuzzleRequest(controller: 'server', action: 'now'))
      .catchError((error) {
    // should raise an error:
    // KuzzleError[Unable to execute request: not connected to a Kuzzle server.]
    assert(error is KuzzleError);
    print(error);
  });

  kuzzle.connect().then((_) async {
    // this query should not be queued and resolved when answered
    final now = await kuzzle.server.now();
    print('[result][server][now] $now');

    var user = await kuzzle.auth.getCurrentUser();
    print('[result][auth][getCurrentUser] 1 $user');

    final token = await kuzzle.auth.login('local', <String, dynamic>{
      'username': 'awesome',
      'password': 'p@ssw0rd',
    });
    print('[result][auth][login] $token');

    user = await kuzzle.auth.getCurrentUser();
    print('[result][auth][getCurrentUser] 2 $user');

    final results = await kuzzle.document
        .search('myindex', 'mycollection', query: <String, dynamic>{
      'query': <String, dynamic>{
        'match': <String, dynamic>{
          '_kuzzle_info.author': user.uid,
        }
      }
    });
    print(results.hits);

    final roomId = await kuzzle.realtime
        .subscribe('myindex', 'mycollection', <String, dynamic>{}, (response) {
      print('[subscription] $response');
    });
    print('subscribed to room $roomId');
  });

  // perform a query when connection status is not known
  kuzzle
      .query(KuzzleRequest(controller: 'server', action: 'now'))
      .then((response) {
    // this query should be queued and resolved when connected & answered
    assert(response is KuzzleResponse);

    print('[response][queued] $response');
  });
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  kuzzle: ^1.0.0-alpha.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:kuzzle/kuzzle.dart';
  
Version Uploaded Documentation Archive
1.0.0-alpha.4 Feb 8, 2019 Go to the documentation of kuzzle 1.0.0-alpha.4 Download kuzzle 1.0.0-alpha.4 archive
1.0.0-alpha.3 Feb 4, 2019 Go to the documentation of kuzzle 1.0.0-alpha.3 Download kuzzle 1.0.0-alpha.3 archive
1.0.0-alpha.2 Feb 4, 2019 Go to the documentation of kuzzle 1.0.0-alpha.2 Download kuzzle 1.0.0-alpha.2 archive
1.0.0-alpha.1 Jan 18, 2019 Go to the documentation of kuzzle 1.0.0-alpha.1 Download kuzzle 1.0.0-alpha.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1

Platforms

Detected platforms: Flutter, other

Primary library: package:kuzzle/kuzzle.dart with components: io.

Maintenance suggestions

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
meta ^1.1.6 1.1.7
pedantic ^1.4.0 1.4.0 1.5.0
uuid ^1.0.3 1.0.3 2.0.0
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
typed_data 1.1.6
Dev dependencies
coverage ^0.12.3
test ^1.5.1+1