6.1.0 • Published 2 years ago

@indicia-js/remote-drupal v6.1.0

Weekly downloads
1
License
GNU GPL v3
Repository
github
Last release
2 years ago

@indicia-js/remote-drupal version Build Status

Drupal 8 indicia-api module data synchronization functions. Helps to synchronize biological records with Indicia Warehouse (through Indicia API Drupal module).

Usage

import { Sample, Occurrence, Media } from '@indicia-js/core';
import withRemote from '@indicia-js/remote-drupal';

const SampleWithRemote = withRemote(Sample);
const OccurrenceWithRemote = withRemote(Occurrence);
const MediaWithRemote = withRemote(Media);

const sample = new SampleWithRemote();

sample.metadata = {
  survey_id: 1,
  training: true, // optional
  confidential: true, // optional
  sensitive: true, // optional
  release_status: 'R', // optional R-eleased/P-recheck/...
  record_status: 'C', // optional C-omplete/I-ncomplete/...
};

sample.remote.url = '<YOUR_API_HOST_URL>';
sample.remote.headers = {}; // can be an async function

sample.attrs.date = '12/2/2012';
sample.attrs.location = '12.345, -12.345';

var occ = new OccurrenceWithRemote();

sample.occurrences.push(occ);

// Upload to Indicia warehouse
await sample.saveRemote();

Initialization

npm i @indicia-js/remote-drupal

Configuration

You can set human friendly warehouse attribute names (ids) and values for both Sample and Occurrence attributes:

So instead of occurrence.attrs[232] = 12343 one can occurrence.attrs.taxon = 'bee', examples:

// Sample.keys
Occurrence.keys = {
  // no value mapping
  certain: {
    id: 398,
  },
  // object
  taxon: {
    id: 232,
    values: {
      1: 272198,
      bee: 12343,
    },
  },
  // array
  weather: {
    id: 122,
    values: [
      { value: 'sunny', id: 272398 },
      { value: 'rainy', id: 132343 },
    ],
  },
  // function
  colour: {
    id: 251,
    values() {
      return 'some calculated value';
    },
  },
};

API

// all models

model.id: null | Number
model.keys: Object | Function
model.getSubmission() ⇒ Array

// Sample
sample.remote: Object
sample.saveRemote() ⇒ Promise

Bugs and feature requests

Have a bug or a feature request? search for existing and closed issues. Please open a new issue.

Creators

Karolis Kazlauskis

Copyright and license

Code and documentation copyright 2020 CEH. Code released under the GNU GPL v3 license.

6.1.0

2 years ago

6.0.0

3 years ago

5.6.9

3 years ago

5.6.7

3 years ago

5.6.6

3 years ago

5.6.5

3 years ago

5.6.2

4 years ago

5.4.4

4 years ago

5.4.3

4 years ago

5.4.2

4 years ago

5.4.1

4 years ago

5.4.0

4 years ago

5.3.0

4 years ago