Giter Club home page Giter Club logo

integreat's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar kjellmorten avatar timharek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

integreat's Issues

Use default values from types

Mapping should use default values defined on types, both when mapping from and to a source.

This involves removing the defaultTo attribute on attributes mappers of source items, as it makes no sense to provide a different default value depending on which way we map. The effect of this differentiation, would lead to unpredictability, as a missing attributed mapped from to source and back again would get a different default value than a missing attribute mapped only to the source.

Retrieve only new items in `sync` job

This involves:

  • Retrieving the lastSyncedAt metadata for the source
  • Passing the updatedAfter param to GET on retrieval, so that the source may retrieve only items updated after this date
  • Filtering out items with updatedAt dates before the last synced date, as a last measurement

Create a `not` mapper

The not mapper will simply turn a true into a false, and opposite. This will be a two-way mapper, and reverse the operation on the way back to the source.

Separate method for returning auth info as object in strategies

The method getAuthHeaders returns valid header key/value pairs in an object, ready for including with a http request.

In many cases this object could also serve as an object in other cases, e.g. as an option object for a mediating request module, but to make the difference clearer, there should also be a getAuthObject to allow these to be different when that makes sense.

Dummy adapter

Write an adapter that will return dummy data of the right type. Allows for testing before the real sources are hooked up.

Rewrite base to give access to generic sources through dispatching actions

Simplify base functionality to focus on access to sources only.

A source may be reached by dispatching an action, and the action is routed to the right source by its type.

const action = {type: 'GET', payload: {id: 'ent1', type: 'entry'}}
const ret = await great.dispatch(action)

With this, there's no longer any need for the connect interface. Other fronts, like REST or GraphQL, may just use the dispatch interface directly.

Catch all on sources

Consider using an asterisk item to signal a catch all source. Possible alias catchAll flag on source.

Treat all 200-statuses as 'ok'.

The json adapter will currently report every status from http requests except 200 as an error. This is obviously wrong and should be handled correctly.

Connect interface

First ideas:

// Connect with item type
const entries = great.connect('entry')

// Get one item of connected type
entries.get('ent1').then((item) => { ... })

// Get all items of connected type
entries.forEach((item) => { ... })

// Get items through filter
entries.where('age').gt(18).or('parentsConsent').eq(true).forEach((item) => { ... })

// Set item of connected type
entries.set('ent1', itemObject)

// Remove item of connected type
entries.remove('ent1')

Use type definitions

Type definitions should describe what data to exchange with the sources. Map definitions describe how to convert from sources to these types and back again.

Example:

{
  id: 'entry',
  source: 'entriesDb',
  attributes: {
    'name': {
      type: 'string',
      default: null
    }
  },
  relationships: {
    author: {
      type: 'person',
      default: 'admin'
    }
  }
}

Indicate arrays in paths

This is especially useful when mapping back to a source, otherwise there would not be a way to tell if source is expecting an array when the data has only one item.

Suggestion:

path: 'data.items[]'

Handle database conflicts

When inserting an item and the database returns a conflict error, the module should warn of this, but continue syncing.

Allow schedules to specify job id

When an action with an id is queued, the id is used as a job id.

An id may be specified in a schedule def, and will be passed on to the resulting action.

Complete mapped data with all values from type

When mapping from or to a source, include all attributes and relationships with default values in type definition.

This is done in actions, and should be the default behavior for GET, GET_ALL, and GET_MANY. To get only values defined in the mapper, pass inn mappedValuesOnly: true in the action payload.

Rename get actions and implement params property

The action for getting one item should be named GET_ONE, and the action for getting more items GET.

GET will get from endpoint get, and GET_ONE from getone by default. Both can be overridden with the endpoint property, which specifies the endpoint id to #use.

Both get actions will pass on the params property to the uri generator, along with id and type.

Extract sync functionality as a separate module

This is done to distribute responsibilities in a more clear way, as the first architecture gave a very wide range of tasks to the integreat class.

The sync module will access sources by dispatching integreat actions, and will place all updates in a queue.

Array field type

Field definitions will include types ending in square brackets to indicate when they are transformed from an array. E.g. integer[].

Flush scheduled jobs on `schedule()`

Before scheduling jobs, all scheduled jobs in queue should be flushed. This is to prevent duplication of scheduled jobs and jobs not in the current schedule definition to become unmanaged.

Use queue.flushScheduled().

Redis backed queue

Build as a separat module.

Signature:

(options) => ({
  async push (obj) { ... },
  subscribe (handler) { ...; return subscriptionHandle },
  unsubscribe (subsciptionHandle) { ... }
})

Dispatch events

Should trigger an dispatch event on each dispatch. Listeners will receive the action.

After the dispatch, a dispatched event is triggered. In addition to the action, listeners also receives the result returned from the action handler.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.