wilt 4.0.1

  • README.md
  • changelog.md
  • Example
  • Installing
  • Versions
  • 62

Wilt - both a browser and server based CouchDB client library

Wilt is based on the lightweight SAG PHP CouchDB library available here. Users of this library should recognise the structure of Wilt easily. A common processing body is specialised by the use of browser(dart:html) or server(dart:io) HTTP adapters to allow operation in the browser or the server.

Wilt implements the document/attachment/database storage and manipulation interfaces of SAG along with the utility functions such as get session information etc. It does not directly implement the manipulation of design documents, clients however can manipulate these items by constructing their own URL's and using the basic httpRequest method.

Authentication is provided using the Basic HTML method, cookie authentication is not supported.

Wilt is a fully functional standalone library, however it is envisaged that higher level client specific application layers will be wrapped around Wilt to add specific CouchDB response parsing as Wilt returns JSON Objects(or strings) to the client. It has no knowledge of correct/incorrect responses such as conflict errors for instance, i.e it has no real CouchDB intelligence other than supplying success or error responses from its HTTP interface adapter.

Note that the Wilt methods that previously returned Json Objects(JsonObjectLite) now return the dynamic type, this is a JsonObjectLite and can be used as such. This change was necessitated as part of the Dart 2.0 updates.

Current version supports both CouchDb 2.2.0 and 1.6.

4.0.1

Pub analysis fixes

4.0.0

Update to Dart 2.0, issue 25

3.4.1

Correct the SDK version constraint for Flutter

3.4.0

Strong mode updates, switch to json_object_lite. Major test refactor Wilt now compiles under the dev compiler, tests factored into common and platform specific.

3.3.0

Update to latest packages/Dart environment. Retire the completion tests.

3.2.0

Issues 15, 21, 22 and 23.

3.1.2

Update to latest HTTP package

3.1.1

Issue 17, CouchDb 1.6.1 updates

3.1.0

Updates for Issues 13, 11 and 14

3.0.1

Updates for Dart V1.5.3, all tests running.

3.0.0

Issues 8 and 9, this makes Wilt both Browser and Server capable

2.3.0

Issue 7 fixed

2.2.2

Issue 6 fixed

2.2.1

Issue 5 fixed

2.2.0

Issues 3 and 4 fixed.

2.1.0

Standalone attachments added Change notification interface added

2.0.0

Updated for Dart 1.0 release Unit tests now use expectAsync0(() Native adapter success/error response hardening Various bugs NOTE - No API changes.

1.2.0

API docs generated

Updated to use dart:convert

example/wilt.dart

/*
 * Package : WiltServerClient
 * Author : S. Hamblett <steve.hamblett@linux.com>
 * Date   : 03/09/2018
 * Copyright :  S.Hamblett
 */

import 'package:wilt/wilt.dart';
import 'package:wilt/wilt_server_client.dart'; // Comment out for browser.
//import 'package:wilt/wilt_browser_client.dart'; Uncomment for browser
import '../test/lib/wilt_test_config.dart';
import 'package:json_object_lite/json_object_lite.dart' as jsonobject;

/// A simple Wilt client example.
/// Please adjust the settings in wilt_test_config to suite your CouchDb setup.
/// If you are using the browser test please check your CORS settings in CouchDB.
/// For more detailed examples of the API see the test suite.
///
void main() async {
  /// Create a test client
  final WiltServerClient wilting =
      new WiltServerClient(hostName, serverPort, scheme);

  /// Or for the browser
  /// final WiltBrowserClient wilting =
  //  new WiltBrowserClient(hostName, port, scheme);

  // Login if we are using authentication. If you are using authentication
  // try the example with this commented out, you should see all the operations fail
  // with 'not authorised'.
  if (userName != null) {
    wilting.login(userName, userPassword);
  }

  /// Create an example database
  dynamic res = await wilting.createDatabase("wilt_example");
  if (!res.error) {
    final dynamic successResponse = res.jsonCouchResponse;
    if (successResponse.ok) {
      print("EXAMPLE:: Example database created OK");
    } else {
      print("EXAMPLE:: Example database creation failed");
    }
  } else {
    print("EXAMPLE:: Example database creation failed");
  }

  /// Create a test document
  wilting.db = "wilt_example";
  String returnedDocRev;
  final String putId = 'exampletestid';
  final dynamic document = new jsonobject.JsonObjectLite();
  document.title = "Created by a Put Request";
  document.version = 1;
  document.author = "SJH";
  res = await wilting.putDocument(putId, document);
  if (!res.error) {
    final dynamic successResponse = res.jsonCouchResponse;
    if (successResponse.ok) {
      returnedDocRev = WiltUserUtils.getDocumentRev(successResponse);
      print(
          "EXAMPLE:: Example document created OK, revision is $returnedDocRev");
    } else {
      print("EXAMPLE:: Example document creation failed");
    }
  } else {
    print("EXAMPLE:: Example document creation failed");
  }

  /// Update the document to version 2, note we now supply the returned document revision from above.
  document.version = 2;
  res = await wilting.putDocument(putId, document, returnedDocRev);
  if (!res.error) {
    final dynamic successResponse = res.jsonCouchResponse;
    if (successResponse.ok) {
      returnedDocRev = WiltUserUtils.getDocumentRev(successResponse);
      print(
          "EXAMPLE:: Example document updated OK, revision is $returnedDocRev");
    } else {
      print("EXAMPLE:: Example document update failed");
    }
  } else {
    print("EXAMPLE:: Example document update failed");
  }

  /// Read it back
  res = await wilting.getDocument(putId);
  if (!res.error) {
    final dynamic successResponse = res.jsonCouchResponse;
    returnedDocRev = WiltUserUtils.getDocumentRev(successResponse);
    print("EXAMPLE:: Example document read OK, revision is $returnedDocRev");
    print(
        "EXAMPLE:: Example document read OK, title is ${successResponse.title}");
    print(
        "EXAMPLE:: Example document read OK, version is ${successResponse.version}");
    print(
        "EXAMPLE:: Example document read OK, author is ${successResponse.author}");
  } else {
    print("EXAMPLE:: Example document read failed");
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  wilt: ^4.0.1

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:wilt/wilt.dart';
  
Version Uploaded Documentation Archive
4.0.1 Sep 3, 2018 Go to the documentation of wilt 4.0.1 Download wilt 4.0.1 archive
4.0.0 Sep 3, 2018 Go to the documentation of wilt 4.0.0 Download wilt 4.0.0 archive
3.4.1 Apr 2, 2018 Go to the documentation of wilt 3.4.1 Download wilt 3.4.1 archive
3.4.0 Dec 13, 2017 Go to the documentation of wilt 3.4.0 Download wilt 3.4.0 archive
3.3.0 Jul 19, 2017 Go to the documentation of wilt 3.3.0 Download wilt 3.3.0 archive
3.2.0 Nov 26, 2015 Go to the documentation of wilt 3.2.0 Download wilt 3.2.0 archive
3.1.2 Nov 5, 2015 Go to the documentation of wilt 3.1.2 Download wilt 3.1.2 archive
3.1.1 Aug 24, 2015 Go to the documentation of wilt 3.1.1 Download wilt 3.1.1 archive
3.1.0 Sep 4, 2014 Go to the documentation of wilt 3.1.0 Download wilt 3.1.0 archive
3.0.0 Mar 12, 2014 Go to the documentation of wilt 3.0.0 Download wilt 3.0.0 archive

All 19 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:wilt/wilt.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
crypto >=2.0.1 <3.0.0 2.0.6
http ^0.11.3+13 0.11.3+17 0.12.0
json_object_lite ^2.0.0 2.0.0
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
convert 2.0.2
http_parser 3.1.3
meta 1.1.6
path 1.6.2
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6
Dev dependencies
build_runner ^0.10.0
build_test ^0.10.2
build_web_compilers ^0.4.0
coverage ^0.12.2
dart_style ^1.1.3
dartdoc ^0.20.3
test ^1.3.0