kuzzle 1.0.0-alpha.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

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 pub get

Alternatively, your editor might support pub get or flutter pub 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
34
Health:
Code health derived from static analysis. [more]
62
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

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

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

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

Health suggestions

Fix lib/src/controllers/security.dart. (-18.98 points)

Analysis of lib/src/controllers/security.dart reported 42 hints, including:

line 17 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 31 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 50 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 68 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 85 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/src/controllers/document.dart. (-8.17 points)

Analysis of lib/src/controllers/document.dart reported 17 hints, including:

line 16 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 31 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 49 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 66 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 82 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/src/controllers/collection.dart. (-5.36 points)

Analysis of lib/src/controllers/collection.dart reported 11 hints, including:

line 17 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 37 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 50 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 66 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 79 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix additional 10 files with analysis or formatting issues. (-12.36 points)

Additional issues in the following files:

  • lib/src/controllers/index.dart (9 hints)
  • lib/src/controllers/server.dart (7 hints)
  • lib/src/kuzzle/room.dart (2 hints)
  • lib/src/controllers/bulk.dart (1 hint)
  • lib/src/kuzzle/profile.dart (1 hint)
  • lib/src/kuzzle/user.dart (1 hint)
  • lib/src/search_result/abstract.dart (1 hint)
  • lib/src/search_result/profiles.dart (1 hint)
  • lib/src/search_result/roles.dart (1 hint)
  • lib/src/search_result/users.dart (1 hint)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (uuid).

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.8
pedantic ^1.4.0 1.9.0
uuid ^1.0.3 1.0.3 2.0.4
Transitive dependencies
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
typed_data 1.1.6
Dev dependencies
coverage ^0.12.3
test ^1.5.1+1