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

dealcloud-js

v1.0.4

Published

a project to connect to Dealcloud

Downloads

14

Readme

#DealCloud

Other Resources

Dealcloud-Python

install

    npm install dealcloud-js

Examples

Create Client

    const dealcloud = require('dealcloud-js');
    const params = {
        username: '[email protected]',
        password: 'password'
        url: 'https://schema.dealcloud.{com|eu}'
    };

    const client = await dealcloud.createClient(params,{});

No Parameters

These methods do not require or accept any params.

Get Currencies

    const dealcloud = require('dealcloud-js');
    const params = {
        username: '[email protected]',
        password: 'password'
        url: 'https://schema.dealcloud.{com|eu}'
    };

    const client = await dealcloud.createClient(params,{});
    const currencies = await dealcloud.getCurrencies(client);

Get Lists

    const dealcloud = require('dealcloud-js');
    const params = {
        username: '[email protected]',
        password: 'password'
        url: 'https://schema.dealcloud.{com|eu}'
    };

    const client = await dealcloud.createClient(params, {})
    const result = await dealcloud.getLists(client);

Get Fields

    const dealcloud = require('dealcloud-js');
    const params = {
        username: '[email protected]',
        password: 'password'
        url: 'https://schema.dealcloud.{com|eu}'
    };

    const client = await dealcloud.createClientAsync(params, {})
    const result = await dealcloud.getFields(client);

Parameters

These methods require params.

Modified Entries

    const dealcloud = require('dealcloud-js');
    const params = {
        username: '[email protected]',
        password: 'password'
        url: 'https://schema.dealcloud.{com|eu}'
    };

    const fromDate = "2018-10-26T21:32:52"; //can be any valid date format
    const client = await dealcloud.createClient(params, {});
    const result = await dealcloud.getModifiedEntries({client, entryListId, fromDate});

Filtered Entries

    function Value(arg, argType="string") {

        return {
            $attributes: {
                "$xsiType": `{http://www.w3.org/2001/XMLSchema}xsd:${argType}`,
            },
            $value: arg
        }
    }

    const filterInfo = [{
        FieldId: 58743,
        FilterOperation: "StartsWith",
        Value: Value("G")
    }]
    const entryListId = 67337; //Id parameter returned by getLists
    const srcFilters = {FilterInfo: filterInfo};
    const client = await dealcloud.createClientAsync(params)
    const result = await dealcloud.getFilteredEntries({client, entryListId, srcFilters});

Chains

These methods require a parameter returned by one or more of the No Params methods

Get Entries

    const dealcloud = require('dealcloud-js');
    const params = {
        username: '[email protected]',
        password: 'password'
        url: 'https://schema.dealcloud.{com|eu}'
    };

    const entryListId = 67337; //Id parameter returned by getLists
    const client = await dealcloud.createClientAsync(params, {})
    const result = await dealcloud.getListEntries({client, entryListId});

Get Records

    const client = await dealcloud.createClientAsync(params, {})

    // Getting Lists
    const entryLists = await dealcloud.getLists(client);

    // Getting Fields
    const allfields = await dealcloud.getFields(client);

    // Random entry list
    const entryList = entryLists[Math.floor(Math.random() * entryLists.length)];

    const entries = await dealcloud.getListEntries({client, entryListId: entryList.Id});
    const entryFields = _.filter(allfields, {'EntryListId': entryList.Id})

    // If pulling against an empty entry list could get an error, 
    // this is needed only because i'm pulling from random entry lists
    if (entries == null){
        return [];
    }

    /**
     * If filtering, run this loop twice, first only for fields that you would like to filter on but for all entries
     * Filter DCPull results however you'd like
     * Run this loop again for all fields, but only for the filtered entries
     */
    entries.NamedEntry.forEach(entry => {
        //With Schema replace this with a for in or for of loop and loop through properties of schema
        entryFields.forEach(field => {
            //Get All Fields
            DCPulls.push(new DCPull(fieldId = field.Id, entryId = entry.Id))
        })
    });

    // Without Batching
    // const result = await processDCPullAsync(client, DCPulls)

    // Batching DCPulls into batching of 10k pulls, can specify alternate batch sizes
    const result = await batchDCPulls(client, DCPulls);
    return result;

The actual batching function

async function batchDCPulls(client, DCPulls, batchSize = 10000) {
    const manyBatchedDCPulls = _
        .chain(DCPulls)
        .chunk(batchSize)
        .map(f => processDCPullAsync(client, f))
        .value();
        
    const manyResults = await Promise.all(manyBatchedDCPulls);
    const result = _.flatten(manyResults)
    return result;
}

the dcpull function

async function processDCPullAsync(client, DCPulls) {
    const result = await dealcloud.processDCPullAsync({client, DCPulls});
    return result;
};

Create Records