@ztimson/pumpkinpie
Node module for full Datalynk compatability
Last updated 10 months ago by ztimson .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @ztimson/pumpkinpie 
SYNC missed versions from official npm registry.

PumpkinPie

A front end framework to work with Datalynk

pipeline status

This is a library to provide full Datalynk support to any JS framework or app, it supports both promises and RxJS.

Table of Contents

Quick Start

  1. Install Pumpkin Pie
npm install --save @ztimson/pumpkinpie

yarn add @ztimson/pumpkinpie
  1. Add generator script to package.json
{
  "name": "example",
  "scripts": {
    "generate": "generate <spoke> [login] [password]", // <---- Login/Password optional
  },
  ...
  1. Generate the models. If you didn't hard code the login/password you will be prompted. The generated files will be created under the 'models' folder in the current working directory. Feel free to move them.
npm run generate
> Login: example
> Password: ********

yarn generate
> Login: example
> Password: ********
  1. Create an API object
import {API} from '@ztimson/pumpkinpie'

const api = new API('http://example.auxiliumgroup.com/api');
  1. Import the generated models and start using them with the slice object
import {User} from './models/User.model';
import {Slices} from './models/slices';

// Passing the User model into the slice as a generic provides full intellisense
// Slices is an enumerable of Slice IDs to make life easier

api.slice<User>(Slices.User).select().exec().then(ignore => {});

Documentation

This library has auto generated documentation that can be found here.

API

The API layer provides the an object to handles making requests. It will automatically convert any data types, cache on going requests to prevent duplicates and, unless disabled, will bundle requests made at the same time (default 100ms delay to wait for requests) together to minimize network usage.

Generator

An experimental CLI tool to generate a slices enumerable that holds all the slice IDs. It also generates interfaces to represent the data of each slice. It takes into account the name, readonly, required and type. In the case of selection dropdowns, checkbox's, or radio buttons a companion enumerable is generated to proved type strict comparisions.

Slice

The slice layer is a generic object which will construct requests for you. It should be partnered with the generator and its models to provide intellisense and type safe calls.

Examples

Login

const api = new API('https://example.auxiliumgroup.com');

api.request({'$/auth/login': {login: 'user', password: '123'}}).then(user => ...)

Async/Away

const api = new API('https://example.auxiliumgroup.com');

let user = await api.request({'$/auth/login': {login: 'user', password: '123'}})

Select all from slice

const api = new API('https://example.auxiliumgroup.com');

let rows = await api.slice(12345).select().exec().rows();
// rows value: [{}, {}, ...]

Select single item from slice

const api = new API('https://example.auxiliumgroup.com');

let row = await api.slice(12345).select(12345).exec().row();
// row value: {a: 1, b: 2, ...}

Insert

const api = new API('https://example.auxiliumgroup.com');

let keys = await api.slice(12345).insert([
    {first: 'Adam', last: 'Bilbo'},
    {first: 'Charlie', last: 'DeMont'}
]).exec().keys();
// keys value: [1, 2]

Update user

const api = new API('https://example.auxiliumgroup.com');

let success = await api.slice(12345)
    .update({id: 1, first: 'Adam', last: 'Baxter'}).exec().key();
// success value: 1

Add a flag to all users who are underage

const api = new API('https://example.auxiliumgroup.com');

let users = await api.slice(12345).select().exec().rows();
api.slice(1245).update(
    users.map(user => Object.assign(user, {flag: user.age < 18}))
).exec();

Current Tags

  • 1.8.9                                ...           latest (10 months ago)

20 Versions

  • 1.8.9                                ...           10 months ago
  • 1.8.7                                ...           10 months ago
  • 1.8.6                                ...           10 months ago
  • 1.8.5                                ...           10 months ago
  • 1.8.4                                ...           10 months ago
  • 1.8.3                                ...           10 months ago
  • 1.8.2                                ...           10 months ago
  • 1.8.1                                ...           10 months ago
  • 1.8.0                                ...           10 months ago
  • 1.7.4                                ...           10 months ago
  • 1.6.3                                ...           a year ago
  • 1.5.2                                ...           a year ago
  • 1.4.2                                ...           a year ago
  • 1.4.1                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 22
Dependencies (6)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |