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

navodata

v1.1.12

Published

Constructs URL for sending web service request to NAV / BC

Downloads

21

Readme

Odata

Introduction

Odata is a protocol for creating and consuming REST Apis. In Microsoft Dynamics NAV and Microsoft Dynamics 365 Business Central (BC), OData is one of two alternative options (the other is SOAP) of exposing data in an ERP database to the outside world as a web service.

Odata APIs accept either XML (application/atom+xml) or JSON (application/json) for responses. The most recent version of Odata, OdataV4, is mostly consumed as JSON.

The role of this package is to provide an easy and declarative way of describing and therefore creating the URL that should be used when making a request to the NAV / BC web server.

Initialization - prepare

Before you can create a request URL, you must do an initialization step. You prepare the query that will be used to generate URLs for a specific NAV server and company. This is done as follows

const baseUrl = 'http:http://junit:7148/BC140/ODataV4'
const companyName = 'AVSI Kampala'
const query = prepare(baseUrl, companyName)

Once that's done, you can go ahead to create URLs using the query function returned by prepare.

Creating URLs - query

The query function produced by prepare accepts an object that details the kind of URL you want to create.

Here is an example:

const serviceName = 'MyTimesheetList'
const url = query({ serviceName })
// url: http://junit:7148/BC140/ODataV4/Company('AVSI%20Kampala')/MyTimesheetList?%24format=json

Here is another example:

const url = query({
    serviceName,
    orderby: {
        property: 'Project',
        isDescending: true
    }
})
// url: http://junit:7148/BC140/ODataV4/Company('AVSI%20Kampala')/MyTimesheetList?%24orderby=Project+desc&%24format=json
                

Third example

const url = query({
    serviceName,
    filter: {
        property: 'Description',
        startswith: 'Did '
    }
})
// url: http://junit:7148/BC140/ODataV4/Company('AVSI%20Kampala')/MyTimesheetList?%24filter=startswith%28Description%2C%27Did+%27%29&%24format=json       

Below is an object with all available properties for the object passed to query.

const queryOptions = {
    serviceName,
    id, // get resource by id
    count, // boolean, whether to include the number of items 
    top, // number, how many items to return
    skip, // number, how many items to skip
    filter, //  object, has 2 properties: property, and one of: endswith, startswith, equals, contains
    orderby, // object, has 2 properties: property, isDescending
    select, // list, specify which properties to include per item
    disableJson // boolean, whether to remove the json format query param
}

When id is present, properties that apply to a collection such as top, orderby etc should not be used.