npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

next-engine

v1.0.3

Published

Nextengine API for Nodejs

Downloads

370

Readme

node-nextengine

CircleCI codecov

NPM

A Nodejs wrapper for the Next Engine API http://api.next-e.jp

Installation

npm i -S next-engine

Usage

please read API Document.

Authorize

See passport-nextengine source and demo application

Basic request

const Nextengine = require('next-engine')

const client = new Nextengine({
  clientId: 'XXXXXXXXXX',
  clientSecret: 'XXXXXXXXXX',
  accessToken: 'XXXXXXXXXX',
  refreshToken: 'XXXXXXXXXX'
})

client.request('/api_v1_receiveorder_base/count', {
  'receive_order_shop_id-eq': 1
})
  .then(res => console.log('then:', res.count))
  .catch(e => console.error('catch:', e))

Note

We strongly recommended that you don't use request method.
Because it depends strongly on v1 specification.
Utility methods (query -> get|count|getInBatches, create, update, upload, waitFor and uploadAndWaitFor) are To reduce the dependency of v1.
So please use utility methods as far as possible.

Query utility

// Query by path string(ex. /api_v1_receiveorder_base/count)
client.query('receiveorder_base')
  .where('receive_order_date', '>=', '2016-12-25 23:59:59')
  .count()
  .then(count => console.log(count))

// Query by Entity object
const { ReceiveOrder } = require('next-engine/Entity')
client.query(ReceiveOrder)
  .where('receive_order_id', '<>', 1)
  .count()
  .then(count => console.log(count))

// Get records
const { Goods } = require('next-engine/Entity')
client.query(Goods)
  .where('goods_id', 'abc')
  .limit(500)
  .offset(350)
  .get()
  .then(results => console.log(results))

// Get all records in batch
const { ReceiveOrder } = require('next-engine/Entity')
client.query(ReceiveOrder)
  .limit(300)
  .getInBatches(partial => console.log(partial))
  .then(() => console.log('Done'))

Create / Update utility

// Create shop
const { Shop } = require('next-engine/Entity')
const opts = {
  data: `
    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <shop>
        <shop_mall_id>1</shop_mall_id>
        <shop_name>楽天店</shop_name>
        <shop_abbreviated_name>raku</shop_abbreviated_name>
        <shop_tax_id>1</shop_tax_id>
        <shop_tax_calculation_sequence_id>1</shop_tax_calculation_sequence_id>
        <shop_currency_unit_id>1</shop_currency_unit_id>
      </shop>
    </root>
  `
}

client.create(Shop, opts)
  .then(res => res.result)

// Update shop
const { Shop } = require('next-engine/Entity')
const opts = {
  receive_order_id: 1,
  receive_order_last_modified_date: '2016/01/01 00:00:00',
  data: `
    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <receiveorder_base>
        <receive_order_shop_cut_form_id>12345-6789</receive_order_shop_cut_form_id>
        <receive_order_date>2014-05-01 00:00:00</receive_order_date>
      </receiveorder_base>
      <receiveorder_row>
        <receive_order_row_no value="1">
          <receive_order_row_goods_name>テスト商品</receive_order_row_goods_name>
          <receive_order_row_cancel_flag>1</receive_order_row_cancel_flag>
        </receive_order_row_no>
        <receive_order_row_no value="2">
          <receive_order_row_goods_name>テスト商品2</receive_order_row_goods_name>
        </receive_order_row_no>
        <receive_order_row_no value="3">
          <receive_order_row_quantity>3</receive_order_row_quantity>
        </receive_order_row_no>
      </receiveorder_row>
    </root>
  `
}

client.update(Shop, opts)
  .then(res => res.result)

Upload / Queue utility

const zlib = require('zlib')
const promisify = require('es6-promisify')
const stringify = promisify(require('csv-stringify'))
const deflate = promisify(zlib.deflate)
const { UploadQueue } = require('next-engine/Entity')

input = [
  ['syohin_code', 'jan_code'],
  [ 'abc', '1234567890' ]
]
stringify(input)
  .then(csv => deflate(csv))
  .then(gz => client.upload({ data_type: 'gz', data: gz }))
  .then(queueId => client.waitFor(queueId, [UploadQueue.COMPLETED, UploadQueue.FAILED]))
  .then(() => console.log('Imported!'))

// Or
input = [
  ['syohin_code', 'jan_code'],
  [ 'abc', '1234567890' ]
]
stringify(input)
  .then(csv => deflate(csv))
  .then(gz => client.uploadAndWaitFor({ data_type: 'gz', data: gz }))
  .then(() => console.log('Imported!'))

Contributing

  1. Fork this repository
  2. Create your feature branch & commit
  3. Create a new pull request

License

MIT