{"id":11487,"library":"odata-v4-literal","title":"OData V4 Literal Converter","description":"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.","status":"abandoned","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/jaystack/odata-v4-literal","tags":["javascript","OData","server","V4","literal","typescript"],"install":[{"cmd":"npm install odata-v4-literal","lang":"bash","label":"npm"},{"cmd":"yarn add odata-v4-literal","lang":"bash","label":"yarn"},{"cmd":"pnpm add odata-v4-literal","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import Literal from 'odata-v4-literal';","symbol":"Literal","correct":"import { Literal } from 'odata-v4-literal';"},{"note":"The `require` call returns an object containing the `Literal` utility, not `Literal` directly. Destructuring is the correct approach for CommonJS environments.","wrong":"const Literal = require('odata-v4-literal');","symbol":"Literal (CommonJS)","correct":"const { Literal } = require('odata-v4-literal');"}],"quickstart":{"code":"import { Literal } from 'odata-v4-literal';\n\n// Demonstrate conversion of various OData V4 literal types\nconsole.log('--- OData V4 Literal Conversions ---');\n\n// Edm.String (note the escaping for O'Neill)\nconst string1 = Literal.convert(\"Edm.String\", \"'Hello O''Neill'\");\nconsole.log(`'Hello O''Neill' (Edm.String) -> ${JSON.stringify(string1)} (Type: ${typeof string1})`);\n\n// Another simple Edm.String\nconst string2 = Literal.convert(\"Edm.String\", \"'Another String'\");\nconsole.log(`'Another String' (Edm.String) -> ${JSON.stringify(string2)} (Type: ${typeof string2})`);\n\n// Edm.Int32\nconst int32 = Literal.convert(\"Edm.Int32\", \"123\");\nconsole.log(`123 (Edm.Int32) -> ${JSON.stringify(int32)} (Type: ${typeof int32})`);\n\n// Edm.Decimal / Edm.Double\nconst decimal = Literal.convert(\"Edm.Decimal\", \"123.45\");\nconsole.log(`123.45 (Edm.Decimal) -> ${JSON.stringify(decimal)} (Type: ${typeof decimal})`);\n\n// Edm.Boolean\nconst booleanTrue = Literal.convert(\"Edm.Boolean\", \"true\");\nconsole.log(`true (Edm.Boolean) -> ${JSON.stringify(booleanTrue)} (Type: ${typeof booleanTrue})`);\n\nconst booleanFalse = Literal.convert(\"Edm.Boolean\", \"false\");\nconsole.log(`false (Edm.Boolean) -> ${JSON.stringify(booleanFalse)} (Type: ${typeof booleanFalse})`);\n\n// Edm.Guid\nconst guid = Literal.convert(\"Edm.Guid\", \"80336209-66cb-4034-8b63-952467d344ff\");\nconsole.log(`80336209-66cb-4034-8b63-952467d344ff (Edm.Guid) -> ${JSON.stringify(guid)} (Type: ${typeof guid})`);\n\n// Edm.DateTimeOffset (ISO 8601 format)\nconst dateTimeOffset = Literal.convert(\"Edm.DateTimeOffset\", \"2023-01-15T10:30:00Z\");\nconsole.log(`2023-01-15T10:30:00Z (Edm.DateTimeOffset) -> ${JSON.stringify(dateTimeOffset)} (Type: ${typeof dateTimeOffset})`);\n\n// Edm.Date\nconst date = Literal.convert(\"Edm.Date\", \"2023-01-15\");\nconsole.log(`2023-01-15 (Edm.Date) -> ${JSON.stringify(date)} (Type: ${typeof date})`);\n\n// Example of a potentially malformed literal (unquoted string for Edm.String)\ntry {\n    // This will likely throw an error or return null/undefined depending on implementation\n    const malformed = Literal.convert(\"Edm.String\", \"Unquoted String\");\n    console.log(`'Unquoted String' (malformed Edm.String) -> ${JSON.stringify(malformed)}`);\n} catch (e: any) {\n    console.error(`Error converting malformed string literal: ${e.message}`);\n}","lang":"typescript","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"breaking","affected_versions":">=0.1.1"},{"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'`.","message":"OData 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.","severity":"gotcha","affected_versions":">=0.1.1"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"The `Literal` object was not correctly imported or accessed from the package's module export.","error":"Cannot read properties of undefined (reading 'convert') or similar TypeError"},{"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).","cause":"The input string does not conform to the expected OData V4 literal format for the specified EDM type.","error":"Error: Unrecognized literal format or Malformed OData literal"}],"ecosystem":"npm"}