Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@odata2ts/odata-core

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@odata2ts/odata-core

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

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by17.55%
Maintainers
0
Weekly downloads
 
Created
Source

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 TypeDescriptionURL formatURL ExampleJSON type
Edm.Booleanboolean valueliteraltrue
false
boolean
Edm.Stringstring valuequoted'Some Test'string
Edm.Byteunsigned 8-bit integer valueliteral1number
Edm.SBytesigned 8-bit integer valueliteral-1number
Edm.Int16signed 16-bit integer valueliteral123number
Edm.Int32signed 32-bit integer valueliteral123number
Edm.Int64signed 64-bit integer valueliteral123number
Edm.Singlefloating point number with 7 digits precisionliteral1.1number
Edm.Doublefloating point number with 15 digits precisionliteral1.2number
Edm.Decimalnumeric values with arbitrary precision and scaleliteral12.22number
Edm.Guid16-byte (128-bit) unique identifier valueliteral...string
Edm.DurationdurationliteralPT12H59M10S
P1Y
PT12.123S
string
Edm.TimeOfDayspecific time of dayliteral12:59:10
12:15
12:15:03.123
string
Edm.Datespecific dayliteral2022-12-31string
Edm.DateTimeOffsetspecific point in timeliteral2022-12-31T23:59:59Z
2022-12-31T23:59:59+02:00
string
Edm.Binaryfixed or variable length binary database64 encoded string
Edm.Streammost 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 TypeDescriptionURL formatURL exampleJSON typeJSON example
Edm.Booleanboolean valueliteraltruebooleantrue
Edm.Stringstring valuequoted'test'string"test"
Edm.Byteunsigned 8-bit integer valueliteral1string"1"
Edm.SBytesigned 8-bit integer valueliteral-1string"-1"
Edm.Int16signed 16-bit integer valueliteral123number123
Edm.Int32signed 32-bit integer valueliteral123number123
Edm.Int64signed 64-bit integer valuetype suffix "L"123Lstring"123"
Edm.Singlefloating point number with 7 digits precisiontype suffix "f"1.1fstring"1.1"
Edm.Doublefloating point number with 15 digits precisiontype suffix "d"1.2dstring"1.2"
Edm.Decimalnumeric values with arbitrary precision and scaletype suffix "M" or "m"12.22Mstring"12.22
Edm.Guid16-byte (128-bit) unique identifier valuetype prefix "guid"guid'xxx...'string"xxx..."
Edm.Timeday time duration representing time of daytype prefix "time"time'PT12H59M10S'string"PT12H59M10S"
Edm.DateTimespecific point in timetype prefix "datetime"datetime'2022-12-31T23:59:59'string"/Date(123...)/"
Edm.DateTimeOffsetspecific point in timetype prefix "datetimeoffset"datetimeoffset'2022-12-31T23:59:59Z'string"2022-12-31T23:59:59+01:00"
Edm.Binaryfixed or variable length binary datatype 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.

Keywords

FAQs

Package last updated on 25 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc