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

@odata2ts/odata-core

v0.6.0

Published

Enums and interfaces for OData V2 and V4 data types and response models

Downloads

44,092

Readme

npm (scoped)

OData Core

Bundles central and constant information about OData as protocol, like the versions or data types. As such this package has no dependencies and can be used for any purpose.

Contains enumerations of

  • the main OData versions, i.e. V2 and V4
  • all V2 data types
  • all V4 data types

Contains interfaces for

  • V2 Response Models
  • V4 Response Models

Installation

npm install --save @odata2ts/odata-core

V4 Data Types

| OData V4 Type | Description | URL format | URL Example | JSON type |
|--------------------|---------------------------------------------------------------------|------------|:----------------------------------------------------|-----------------------| | Edm.Boolean | boolean value | literal | truefalse | boolean | | Edm.String | string value | quoted | 'Some Test' | string | | Edm.Byte | unsigned 8-bit integer value | literal | 1 | number | | Edm.SByte | signed 8-bit integer value | literal | -1 | number | | Edm.Int16 | signed 16-bit integer value | literal | 123 | number | | Edm.Int32 | signed 32-bit integer value | literal | 123 | number | | Edm.Int64 | signed 64-bit integer value | literal | 123 | number | | Edm.Single | floating point number with 7 digits precision | literal | 1.1 | number | | Edm.Double | floating point number with 15 digits precision | literal | 1.2 | number | | Edm.Decimal | numeric values with arbitrary precision and scale | literal | 12.22 | number | | Edm.Guid | 16-byte (128-bit) unique identifier value | literal | ... | string | | Edm.Duration | duration | literal | PT12H59M10S P1Y PT12.123S | string | | Edm.TimeOfDay | specific time of day | literal | 12:59:1012:15 12:15:03.123 | string | | Edm.Date | specific day | literal | 2022-12-31 | string | | Edm.DateTimeOffset | specific point in time | literal | 2022-12-31T23:59:59Z 2022-12-31T23:59:59+02:00 | string | | Edm.Binary | fixed or variable length binary data | | | base64 encoded string | | Edm.Stream | most filter operations don't work here also exclusive handling | | | | | Edm.Geography.* | | | | | | Edm.Geometry.* | | | | |

V2 Data Types

The special thing about V2 OData services is, that we have to differentiate between using OData types in the URL or in JSON, since they are formatted differently:

  • URL: values in filter queries ($filter) or function parameters (which are query parameters)
  • JSON: values in request or response bodies

The following table lists information about all V2 data types according to the official resources used.

For URL usage, see chapter 6 "Primitive Data Types" of the V2 overview document. This is the most authoritative resource despite it's lack of being a true specification.

For JSON usage, see chapter 4 "Primitive Types" of the document about the V2 JSON format.

| OData V2 Type | Description | URL format | URL example | JSON type | JSON example |
|--------------------|--------------------------------------------------|------------------------------|:-------------------------------------|-----------------------|--------------------------| | Edm.Boolean | boolean value | literal | true | boolean | true | | Edm.String | string value | quoted | 'test' | string | "test" | | Edm.Byte | unsigned 8-bit integer value | literal | 1 | string | "1" | | Edm.SByte | signed 8-bit integer value | literal | -1 | string | "-1" | | Edm.Int16 | signed 16-bit integer value | literal | 123 | number | 123 | | Edm.Int32 | signed 32-bit integer value | literal | 123 | number | 123 | | Edm.Int64 | signed 64-bit integer value | type suffix "L" | 123L | string | "123" | | Edm.Single | floating point number with 7 digits precision | type suffix "f" | 1.1f | string | "1.1" | | Edm.Double | floating point number with 15 digits precision | type suffix "d" | 1.2d | string | "1.2" | | Edm.Decimal | numeric values with arbitrary precision and scale | type suffix "M" or "m" | 12.22M | string | "12.22 | | Edm.Guid | 16-byte (128-bit) unique identifier value | type prefix "guid" | guid'xxx...' | string | "xxx..." | | Edm.Time | day time duration representing time of day | type prefix "time" | time'PT12H59M10S' | string | "PT12H59M10S" | | Edm.DateTime | specific point in time | type prefix "datetime" | datetime'2022-12-31T23:59:59' | string | "/Date(123...)/" | | Edm.DateTimeOffset | specific point in time | type prefix "datetimeoffset" | datetimeoffset'2022-12-31T23:59:59Z' | string | "2022-12-31T23:59:59+01:00" | | Edm.Binary | fixed or variable length binary data | type prefix "X" or "binary" | binary'23A' | base64 encoded string | "..." |

Edm.DateTime is quite special in multiple ways:

  1. URL and JSON representation are completely different
  2. the JSON representation has quite a unique format
  3. Edm.DateTime is not really consistent with Edm.DateTimeOffset

Another oddity is Edm.Time, since it is defined as duration (by the way, the static "P" stands for "period"). Now the "spec" states, that it should represent a specific time of day and refers to the "day time duration" as definition.

I think that the definition is flawed for two reasons. First, "day time duration" also allows for specifying a period of days, which doesn't overlap with time of day. Second, a duration might be able to represent a time of day, in the sense that a duration of 6 hours and 12 minutes might also represent "06:12", but both data types usually have different restrictions. Time of day requires the specification of hours and minutes, while duration might specify any of its parts, e.g. only seconds "PT12S".

Documentation

No further documentation currently.

Support, Feedback, Contributing

This project is open to feature requests, suggestions, bug reports, usage questions etc. via GitHub issues.

Contributions and feedback are encouraged and always welcome.

See the contribution guidelines for further information.

License

MIT - see License.