Registry / serialization / odata-v4-literal

odata-v4-literal

JSON →
library0.1.1jsnpmunverified

The `odata-v4-literal` package is a focused utility designed to convert OData V4 literal values (represented as strings, e.g., `'Hello'`, `123`, `true`, `2023-01-15T10:30:00Z`) into their corresponding native JavaScript data types. This functionality is essential for applications that parse OData query parameters or expressions and need to process the actual values. The package is currently at version 0.1.1, and its last publish date was over nine years ago, indicating that it is effectively abandoned. There is no active development or defined release cadence. Its primary differentiator is providing a direct, simple method for handling the specific syntax and escaping rules of OData V4 primitive literals, which can be complex for types like strings (requiring double single quotes for embedded apostrophes), dates, and GUIDs. Developers should be aware of its unmaintained status when considering its use in new projects.

npm install odata-v4-literal
INSTALL
IMPORT
SIG · ODATA-V4-LITERAL
O
odata-v4-literal
serializationjavascriptv0.1.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Literal
✓ import { Literal } from 'odata-v4-literal';
✗ import Literal from 'odata-v4-literal';
The package exports `Literal` as a named export from its CommonJS module. While this ESM import generally works with bundlers and Node.js resolution, direct default import is incorrect.
Literal (CommonJS)
✓ const { Literal } = require('odata-v4-literal');
✗ const Literal = require('odata-v4-literal');
The `require` call returns an object containing the `Literal` utility, not `Literal` directly. Destructuring is the correct approach for CommonJS environments.

This quickstart demonstrates how to use `odata-v4-literal` to convert various OData V4 literal string representations into their native JavaScript types, including strings with escaped characters, numbers, booleans, GUIDs, and date/time types. It also shows basic error handling for malformed input.

import { Literal } from 'odata-v4-literal'; // Demonstrate conversion of various OData V4 literal types console.log('--- OData V4 Literal Conversions ---'); // Edm.String (note the escaping for O'Neill) const string1 = Literal.convert("Edm.String", "'Hello O''Neill'"); console.log(`'Hello O''Neill' (Edm.String) -> ${JSON.stringify(string1)} (Type: ${typeof string1})`); // Another simple Edm.String const string2 = Literal.convert("Edm.String", "'Another String'"); console.log(`'Another String' (Edm.String) -> ${JSON.stringify(string2)} (Type: ${typeof string2})`); // Edm.Int32 const int32 = Literal.convert("Edm.Int32", "123"); console.log(`123 (Edm.Int32) -> ${JSON.stringify(int32)} (Type: ${typeof int32})`); // Edm.Decimal / Edm.Double const decimal = Literal.convert("Edm.Decimal", "123.45"); console.log(`123.45 (Edm.Decimal) -> ${JSON.stringify(decimal)} (Type: ${typeof decimal})`); // Edm.Boolean const booleanTrue = Literal.convert("Edm.Boolean", "true"); console.log(`true (Edm.Boolean) -> ${JSON.stringify(booleanTrue)} (Type: ${typeof booleanTrue})`); const booleanFalse = Literal.convert("Edm.Boolean", "false"); console.log(`false (Edm.Boolean) -> ${JSON.stringify(booleanFalse)} (Type: ${typeof booleanFalse})`); // Edm.Guid const guid = Literal.convert("Edm.Guid", "80336209-66cb-4034-8b63-952467d344ff"); console.log(`80336209-66cb-4034-8b63-952467d344ff (Edm.Guid) -> ${JSON.stringify(guid)} (Type: ${typeof guid})`); // Edm.DateTimeOffset (ISO 8601 format) const dateTimeOffset = Literal.convert("Edm.DateTimeOffset", "2023-01-15T10:30:00Z"); console.log(`2023-01-15T10:30:00Z (Edm.DateTimeOffset) -> ${JSON.stringify(dateTimeOffset)} (Type: ${typeof dateTimeOffset})`); // Edm.Date const date = Literal.convert("Edm.Date", "2023-01-15"); console.log(`2023-01-15 (Edm.Date) -> ${JSON.stringify(date)} (Type: ${typeof date})`); // Example of a potentially malformed literal (unquoted string for Edm.String) try { // This will likely throw an error or return null/undefined depending on implementation const malformed = Literal.convert("Edm.String", "Unquoted String"); console.log(`'Unquoted String' (malformed Edm.String) -> ${JSON.stringify(malformed)}`); } catch (e: any) { console.error(`Error converting malformed string literal: ${e.message}`); }
Debug
Known issues
breakingThe package version is 0.1.1 and has not been updated in over nine years. There are no guarantees of semantic versioning (SemVer) compliance. Future (hypothetical) updates or even minor bug fixes could introduce breaking changes without a major version increment. However, given its abandoned status, no future updates are expected.
fix
Consider alternatives for new projects or thoroughly vet the package's stability and compatibility for existing applications. Pin the exact version used to mitigate unexpected behavior if it were to be updated.
affects: >=0.1.1
gotchaOData V4 string literals require single quotes to be escaped by doubling them (e.g., 'O''Neill' for 'O'Neill'). Incorrectly escaping strings will lead to parsing errors or incorrect values. This is a common pitfall in OData filter expressions.
fix
Always escape single quotes within OData string literals by doubling them. For example, use `'It''s a test'` instead of `'It's a test'`.
affects: >=0.1.1
gotchaThis package is effectively abandoned, with its last publish occurring over nine years ago. This means there will be no future updates, bug fixes, security patches, or compatibility improvements for newer Node.js versions, TypeScript versions, or OData specification changes. Use with caution in new projects, as it may become incompatible or insecure over time.
fix
For new projects, seek actively maintained OData V4 parsing libraries. For existing projects, thoroughly test its behavior in your current environment and be prepared for potential incompatibilities with future platform updates.
affects: >=0.1.1
Errors
Common errors & fixes
Cannot read properties of undefined (reading 'convert') or similar TypeError
The `Literal` object was not correctly imported or accessed from the package's module export.
fix
Ensure you are using `import { Literal } from 'odata-v4-literal';` for ESM or `const { Literal } = require('odata-v4-literal');` for CommonJS to correctly destructure the named export.
Error: Unrecognized literal format or Malformed OData literal
The input string does not conform to the expected OData V4 literal format for the specified EDM type.
fix
Review the OData V4 specification for the correct literal format for the EDM type you are trying to convert. Pay close attention to string delimiters (single quotes), date/time formats (ISO 8601), and special character escaping (e.g., doubling single quotes within a string literal).
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
odata-v4-literal — npm install odata-v4-literal · libregistry