1.0.2 • Published 1 year ago

node-onix v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

node-onix

NPM version

This is a Node.JS library for parsing and generating ONIX files. It includes basic ONIX 2.1 and ONIX 3.0 support.

Installation

$ npm install node-onix

Usage

let onix = require("node-onix");

let xml = onix.create({
    from: {
        company: "RedCards",
        person: "John Doe",
        email: "john@doe.com"
    },
    supplier: {
        name: "ePubDirect",
        availabilityCode: "IP"
    },
    products: [
        {
            // Single record reference which will uniquely identify the product
            record: "book.com-bookId",

            // Notification type
            notification: onix.codes.NOTIFICATION.ADVANCE,

            // ISBN or other id
            id: {
                type: onix.codes.PRODUCTID.ISBN_13,
                value: '9780333370070'
            },

            // Title
            title: "Alice's Adventures in Wonderland",

            // Language code as ISO 639
            language: "eng",

            // List of prices (number or object) or unique "price"
            prices: [
                {
                    amount: 6,
                    currency: 'eur'
                },

                // Number will default to usd currency
                5
            ]
        }
    ]
});

ONIX data can also be parsed, using the following code.

let data = onix.parse('...');