10.0.0 • Published 3 years ago

sengi-client v10.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

Sengi Client

This package is part of the Sengi family.

npm.io npm

A client library for reading and writing documents managed by a Sengi-based service.

Installation

npm install sengi-client

Usage

The SengiClient provides a simple Promised-based interface for accessing a Sengi-based service. It automatically retries transitory errors.

To instantiate a SengiClient you have to provide the following parameters:

  • fetch - A fetch function. If undefined, the node-fetch library is used by default. (This property is used during testing and it's unlikely you need to specify this.)

  • roleNames - An array of the role names held by the user that is making the request.

  • retryIntervals - An array of integers that specify the time to wait before trying again. If undefined, the default retry strategy is 100, 250, 500, 1000, 2000, 4000, 8000, 15000, 30000.

  • url - The url of the Sengi service.

  • logToConsole - True if the client should log out the contents of any fetch calls just before they are invoked. A call is only logged once, even if it has to be repeated due to transitory errors.

const client = new SengiClient({
  roleNames: ['admin'],
  url: 'https://localhost:1234'
})

Methods

This section describes the methods available on the sengi client.

Document MethodsDescription
createDocumentCreate a new document using a DocType constructor.
deleteByDocumentIdDelete a document using it's id.
getDocumentByIdRetrieve a single document using the documents id.
operateOnDocumentInvoke a DocType operation on a document.
patchDocumentApply a merge patch to a document.
queryAllDocumentsRetrieve all the documents in a collection, specifying the fields to include in the result.
queryDocumentsByFilterRetrieve the documents in a collection that match a DocType filter, specifying the fields to include in the result.
queryDocumentsByIdsRetrieve the documents in a collection with the given ids, specifying the fields to include in the result.
upsertDocumentInsert a new document (without calling the DocType constructor) or replace an existing document in the collection.

All of the above methods allow you to supply the following parameters:

  • pathComponents - An array of path components that will be added to the url used to initialise the Sengi-Client.
  • roleNames - An array of data service role names. If supplied these are the only role names that will be sent with the request. If omitted, the role names supplied with the Sengi-Client was constructed will be used.
Enum MethodsDescription
getEnumTypeItemsRetrieve the items that are defined within an enum identified by it's fully qualified name.

Development

Written in Typescript.

Tests are written using Jest with 100% coverage.

npm test

The errors are tested using a mock Sengi service and the supertest framework.

The happy route is tested by spinning up a live Sengi service (using sengi-express) and hitting the end-points over the wire.

Continuous Deployment

Any pushes or pull-requests on non-master branches will trigger the test runner.

Any pushes to master will cause the family of libraries to be re-published.

10.0.0

3 years ago

9.1.0

3 years ago

9.0.0

3 years ago

8.5.0

3 years ago

8.4.4

3 years ago

8.4.3

3 years ago

8.4.2

3 years ago

8.4.1

3 years ago

8.4.0

3 years ago

8.3.0

3 years ago

8.2.0

3 years ago

8.1.1

3 years ago

8.1.0

3 years ago

8.0.0

3 years ago

7.7.3

3 years ago

7.7.2

3 years ago

7.7.1

3 years ago

7.7.0

3 years ago

7.6.1

3 years ago

7.6.0

3 years ago

7.5.0

3 years ago

7.4.0

3 years ago

7.3.2

3 years ago

7.3.1

3 years ago

7.3.0

3 years ago

7.2.1

3 years ago

7.2.0

3 years ago

7.1.0

3 years ago

7.0.0

3 years ago

6.7.0

3 years ago

6.5.0

3 years ago

6.4.1

3 years ago

6.6.0

3 years ago

6.3.3

3 years ago

6.3.2

3 years ago

6.3.1

3 years ago

6.3.0

3 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago