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

linnworks-channel-integration

v1.0.5

Published

Quickly and easily create Express servers for custom Linnworks channel integrations

Downloads

26

Readme

Linnworks Channel Integration Utility

This package is a work-in-progress utility to simplify the process of building and serving custom channel integrations for Linnworks. Written entirely in TypeScript.

Features

  • Automated user management
  • Request and response type interfaces for all supported endpoints
  • Rich logging for requests, responses and errors, courtesy of Winston
  • Automatic manifest generation

Requirements

This package uses Mongoose to manage integration users and store their marketplace credentials, so you will need to have an active MongoDB service running on your server to make use of this library.

Installation

yarn add linnworks-channel-integration / npm i linnworks-channel-integration

Usage

const server = createChannelIntegrationServer({
    channelIdentifier: 'coolMarketplace',
    channelFriendlyName: 'My Cool Marketplace',
    channelLogo: 'cool-logo.png',
    baseUrl: 'https://cool-marketplace.mywebsite.com',
    authFields,
    testChannelIntegration,
    getInventory,
    getOrders,
    dispatchOrders,
});

server.listen(APP_PORT, () => {
    console.log(`Server running on port ${ APP_PORT }`);
});

A manifest file will be created on app launch, which should be copied and pasted into the application manifest on the Linnworks Developer Portal.

Options

channelIdentifier

This should be a unique string with no spaces or special characters. Used as the MongoDB database name.


channelFriendlyName

Used as the channel name in the integration manifest.


channelLogo

This should be the filename for a 57x57 PNG displaying the marketplace logo. The file should be placed inside an 'assets' folder located at the project root.


baseURL

This should be set to the public URL for your marketplace integration. Used when creating the application manifest.


authFields

interface ChannelAuthField {
    id: string;
    label: string;
    description: string;
    secret: boolean;
}

These fields will appear in the integration config screen in Linnworks. Use them to capture the credentials required when authenticating with the marketplace API.

The id and current input value for each field are passed into the marketplace functions as key-value pairs within the authInfo parameter.

N.B. Use secret: true for sensitive credentials (e.g. tokens and passwords)


testChannelIntegration

type ConfigTest = (
    authInfo: { [key: string]: string }
) => Promise<boolean>;

This function should attempt to log into the marketplace using the provided credentials. Only return true if the connection is successful, otherwise return false.


getInventory

type GetInventory = (
    page: number,
    authInfo: { [key: string]: string }
) => Promise<LWProductResponse>;

This function should return a list of marketplace inventory items to enable inventory mapping.

N.B. This library exposes a getLinnworksInventory function which returns your current Linnworks inventory. This enables SKU mapping even if the marketplace does not have an inventory API. Requires axios and the creation of an authField in the channel config with id: 'LWToken'.


getOrders

type GetOrders = (
    page: number,
    lastUpdated: string,
    authInfo: { [key: string]: string }
) => Promise<LWOrdersResponse>;

This function should return all of the active marketplace orders updated since the last succesful fetch.

Format of lastUpdated: ​"yyyy-MM-dd HH:mm:ssZ".


dispatchOrders

type DispatchOrders = (
    orders: LWDispatchOrder[],
    authInfo: { [key: string]: string }
) => Promise<LWDispatchResponse>;

Used to dispatch orders and supply tracking information for the marketplace.

Request and Response Schemas

All LW-prefixed types (e.g. LWOrdersResponse, LWDispatchOrder) are thoroughly documented on the Linnworks Channel Integration Guide.