Module: odata/utils

odata/utils

Methods

<inner> dataItemTypeName(value, metadata) → {string}

Gets the type name of a data item value that belongs to a feed, an entry, a complex type property, or a collection property
Parameters:
Name Type Argument Description
value string Value of the data item from which the type name is going to be retrieved.
metadata object <optional>
Object containing metadata about the data tiem.
Source:
Returns:
Data item type name; null if the type name cannot be found within the value or the metadata This function will first try to get the type name from the data item's value itself if it is an object with a __metadata property; otherwise it will try to recover it from the metadata. If both attempts fail, it will return null.
Type
string

<inner> forEachSchema(metadata, callback)

Invokes a function once per schema in metadata.
Parameters:
Name Type Description
metadata Metadata store; one of edmx, schema, or an array of any of them.
callback function Callback function to invoke once per schema.
Source:
Returns:
The first truthy value to be returned from the callback; null or the last falsy value otherwise.

<inner> formatDateTimeOffset(value) → {String}

Formats a DateTime or DateTimeOffset value a string.
Parameters:
Name Type Description
value Date Value to format
Source:
Returns:
Formatted text. If the value is already as string it's returned as-is ยด
Type
String

<inner> formatDuration(value) → {String}

Converts a duration to a string in xsd:duration format.
Parameters:
Name Type Description
value Object Object with ms and __edmType properties.
Source:
Returns:
String representation of the time object in xsd:duration format.
Type
String

<inner> formatMilliseconds(ms, ns) → {String}

Formats a millisecond and a nanosecond value into a single string.
Parameters:
Name Type Description
ms Number Number of milliseconds to format.
ns Number Number of nanoseconds to format.
Source:
Returns:
Formatted text. If the value is already as string it's returned as-is.
Type
String

<inner> formatNumberWidth(value, width, append) → {String}

Formats the specified value to the given width.
Parameters:
Name Type Description
value Number Number to format (non-negative).
width Number Minimum width for number.
append Boolean Flag indicating if the value is padded at the beginning (false) or at the end (true).
Source:
Returns:
Text representation.
Type
String

<inner> getCanonicalTimezone(timezone) → {String}

Gets the canonical timezone representation.
Parameters:
Name Type Description
timezone String Timezone representation.
Source:
Returns:
An 'Z' string if the timezone is absent or 0; the timezone otherwise.
Type
String

<inner> getCollectionType(typeName) → {String}

Gets the type of a collection type name.
Parameters:
Name Type Description
typeName String Type name of the collection.
Source:
Returns:
Type of the collection; null if the type name is not a collection type.
Type
String

<inner> getEntitySetInfo(entitySetName, metadata) → {Object}

Gets the entitySet info, container name and functionImports for an entitySet
Parameters:
Name Type Description
entitySetName Object -
metadata Object -
Source:
Returns:
The info about the entitySet.
Type
Object

<inner> invokeRequest(request, success, error, handler, httpClient, context)

Sends a request containing OData payload to a server.
Parameters:
Name Type Description
request Object that represents the request to be sent..
success Callback for a successful read operation.
error Callback for handling errors.
handler Handler for data serialization.
httpClient HTTP client layer.
context Context used for processing the request
Source:

<inner> isBatch(value) → {Boolean}

Tests whether a value is a batch object in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
Source:
Returns:
True is the value is a batch object; false otherwise.
Type
Boolean

<inner> isCollection(value, typeName) → {Boolean}

Tests whether a value is a collection value in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
typeName String Type name of the value. This is used to disambiguate from a collection property value.
Source:
Returns:
True is the value is a feed value; false otherwise.
Type
Boolean

<inner> isCollectionType(typeName) → {Boolean}

Checks whether the specified type name is a collection type.
Parameters:
Name Type Description
typeName String Name of type to check.
Source:
Returns:
True if the type is the name of a collection type; false otherwise.
Type
Boolean

<inner> isComplex(value) → {Boolean}

Tests whether a value is a complex type value in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
Source:
Returns:
True is the value is a complex type value; false otherwise.
Type
Boolean

<inner> isDateTimeOffset(value) → {Boolean}

Checks whether a Date object is DateTimeOffset value
Parameters:
Name Type Description
value Date Value to check
Source:
Returns:
true if the value is a DateTimeOffset, false otherwise.
Type
Boolean

<inner> isDeferred(value) → {Boolean}

Tests whether a value is a deferred navigation property in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
Source:
Returns:
True is the value is a deferred navigation property; false otherwise.
Type
Boolean

<inner> isEntry(value) → {Boolean}

Tests whether a value is an entry object in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
Source:
Returns:
True is the value is an entry object; false otherwise.
Type
Boolean

<inner> isFeed(value, typeName) → {Boolean}

Tests whether a value is a feed value in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
typeName String Type name of the value. This is used to disambiguate from a collection property value.
Source:
Returns:
True is the value is a feed value; false otherwise.
Type
Boolean

<inner> isGeographyEdmType(typeName) → {Boolean}

Checks whether the specified type name is a geography EDM type.
Parameters:
Name Type Description
typeName String Name of type to check.
Source:
Returns:
True if the type is a geography EDM type; false otherwise.
Type
Boolean

<inner> isGeometryEdmType(typeName) → {Boolean}

Checks whether the specified type name is a geometry EDM type.
Parameters:
Name Type Description
typeName String Name of type to check.
Source:
Returns:
True if the type is a geometry EDM type; false otherwise.
Type
Boolean

<inner> isNamedStream(value) → {Boolean}

Tests whether a value is a named stream value in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
Source:
Returns:
True is the value is a named stream; false otherwise.
Type
Boolean

<inner> isPrimitive(value) → {Boolean}

Tests whether a value is a primitive type value in the library's internal representation.
Parameters:
Name Type Description
value Value to test.
Source:
Returns:
True is the value is a primitive type value. Date objects are considered primitive types by the library.
Type
Boolean

<inner> isPrimitiveEdmType(typeName) → {Boolean}

Checks whether the specified type name is a primitive EDM type.
Parameters:
Name Type Description
typeName String Name of type to check.
Source:
Returns:
True if the type is a primitive EDM type; false otherwise.
Type
Boolean

<inner> lookupComplexType(name, metadata)

Looks up a complex type object by name.
Parameters:
Name Type Description
name String Name, possibly null or empty.
metadata Metadata store; one of edmx, schema, or an array of any of them.
Source:
Returns:
A complex type description if the name is found; null otherwise.

<inner> lookupDefaultEntityContainer(metadata)

Looks up an
Parameters:
Name Type Description
metadata Metadata store; one of edmx, schema, or an array of any of them.
Source:
Returns:
An entity container description if the name is found; null otherwise.

<inner> lookupEntityContainer(name, metadata)

Looks up an entity container object by name.
Parameters:
Name Type Description
name String Name, possibly null or empty.
metadata Metadata store; one of edmx, schema, or an array of any of them.
Source:
Returns:
An entity container description if the name is found; null otherwise.

<inner> lookupEntitySet(entitySets, name) → {Object}

Looks up a entity set by name.
Parameters:
Name Type Description
entitySets Array Array of entity set objects as per EDM metadata( may be null)
name String Name to look for.
Source:
Returns:
The entity set object; null if not found.
Type
Object

<inner> lookupEntityType(name, metadata)

Looks up an entity type object by name.
Parameters:
Name Type Description
name String Name, possibly null or empty.
metadata Metadata store; one of edmx, schema, or an array of any of them.
Source:
Returns:
An entity type description if the name is found; null otherwise.

<inner> lookupFunctionImport(functionImports, name) → {Object}

Looks up a function import by name.
Parameters:
Name Type Description
functionImports Array Array of function import objects as per EDM metadata (May be null)
name String Name to look for.
Source:
Returns:
The entity set object; null if not found.
Type
Object

<inner> lookupInMetadata(name, metadata, kind)

Looks up a type object by name.
Parameters:
Name Type Description
name String Name, possibly null or empty.
metadata Metadata store; one of edmx, schema, or an array of any of them.
kind String Kind of object to look for as per EDM metadata.
Source:
Returns:
An type description if the name is found; null otherwise

<inner> lookupInSchema(name, schema, kind)

Looks up a schema object by name.
Parameters:
Name Type Description
name String Name (assigned).
schema Schema object as per EDM metadata.
kind String Kind of object to look for as per EDM metadata.
Source:
Returns:
An entity type description if the name is found; null otherwise.

<inner> lookupNavigationPropertyEntitySet(navigationProperty, sourceEntitySetName, metadata) → {String}

Looks up the target entityset name for a navigation property.
Parameters:
Name Type Description
navigationProperty Object -
sourceEntitySetName Object -
metadata Object metadata
Source:
Returns:
The entityset name for the specified property, null if not found.
Type
String

<inner> lookupNavigationPropertyType(navigationProperty, metadata) → {String}

Looks up the target entity type for a navigation property.
Parameters:
Name Type Description
navigationProperty Object -
metadata Object -
Source:
Returns:
The entity type name for the specified property, null if not found.
Type
String

<inner> lookupProperty(properties, name) → {Object}

Looks up a property by name.
Parameters:
Name Type Description
properties Array Array of property objects as per EDM metadata (may be null)
name String Name to look for.
Source:
Returns:
The property object; null if not found.
Type
Object

<inner> lookupSingleton(singletons, name) → {Object}

Looks up a entity set by name.
Parameters:
Name Type Description
singletons Array Array of entity set objects as per EDM metadata (may be null)
name String Name to look for.
Source:
Returns:
The entity set object; null if not found.
Type
Object

<inner> maxVersion(left, right) → {String}

Compares to version strings and returns the higher one.
Parameters:
Name Type Description
left String Version string in the form "major.minor.rev"
right String Version string in the form "major.minor.rev"
Source:
Returns:
The higher version string.
Type
String
Gets the kind of a navigation property value.
Parameters:
Name Type Argument Description
value Value of the navigation property.
propertyModel Object <optional>
Object that describes the navigation property in an OData conceptual schema.
Source:
Returns:
String value describing the kind of the navigation property; null if the kind cannot be determined.
Type
String

<inner> normalizeHeaders(headers)

Normalizes headers so they can be found with consistent casing.
Parameters:
Name Type Description
headers Object Dictionary of name/value pairs.
Source:

<inner> parseBool(propertyValue) → {Boolean}

Parses a string into a boolean value.
Parameters:
Name Type Description
propertyValue Value to parse.
Source:
Returns:
true if the property value is 'true'; false otherwise.
Type
Boolean

<inner> parseDate(propertyValue, nullOnError) → {Date}

Parses a string into a Date object.
Parameters:
Name Type Description
propertyValue String Value to parse.
nullOnError Boolean return null instead of throwing an exception
Source:
Returns:
The parsed with year, month, day set, time values are set to 0
Type
Date

<inner> parseDateTimeMaybeOffset(value, withOffset, nullOnError) → {Date}

Parses a string into a DateTime value.
Parameters:
Name Type Description
value String Value to parse.
withOffset Boolean Whether offset is expected.
nullOnError Boolean return null instead of throwing an exception
Source:
Returns:
The parsed value.
Type
Date

<inner> parseDateTimeOffset(propertyValue, nullOnError) → {Date}

Parses a string into a DateTimeOffset value.
Parameters:
Name Type Description
propertyValue String Value to parse.
nullOnError Boolean return null instead of throwing an exception
Source:
Returns:
The parsed value. The resulting object is annotated with an __edmType property and an __offset property reflecting the original intended offset of the value. The time is adjusted for UTC time, as the current timezone-aware Date APIs will only work with the local timezone.
Type
Date

<inner> parseDuration(duration) → {Object}

Parses a string in xsd:duration format.
Parameters:
Name Type Description
duration String Duration value. This method will throw an exception if the input string has a year or a month component.
Source:
Returns:
Object representing the time
Type
Object

<inner> parseTimeOfDay(propertyValue, nullOnError) → {Object}

Parses a time into a Date object.
Parameters:
Name Type Description
propertyValue
nullOnError Boolean return null instead of throwing an exception
Source:
Returns:
Type
Object

<inner> parseTimezone(timezone) → {Object}

Parses a timezone description in (+|-)nn:nn format.
Parameters:
Name Type Description
timezone String Timezone offset.
Source:
Returns:
An object with a (d)irection property of 1 for + and -1 for -, offset (h)ours and offset (m)inutes.
Type
Object

<inner> prepareRequest(request, handler, context)

Prepares a request object so that it can be sent through the network.
Parameters:
Name Type Description
request Object that represents the request to be sent.
handler Handler for data serialization
context Context used for preparing the request
Source:

<inner> removeNamespace(ns, fullName) → {String}

Given an expected namespace prefix, removes it from a full name.
Parameters:
Name Type Description
ns String Expected namespace.
fullName String Full name in 'ns'.'name' form.
Source:
Returns:
The local name, null if it isn't found in the expected namespace.
Type
String

<inner> traverse(item, callback) → {Object}

Traverses a tree of objects invoking callback for every value.
Parameters:
Name Type Description
item Object Object or array to traverse.
callback function Callback function with key and value, similar to JSON.parse reviver.
Source:
Returns:
The traversed object. Unlike the JSON reviver, this won't delete null members.
Type
Object

<inner> traverseInternal(item, owner, callback) → {Object}

Traverses a tree of objects invoking callback for every value.
Parameters:
Name Type Description
item Object Object or array to traverse.
owner Object Pass through each callback
callback function Callback function with key and value, similar to JSON.parse reviver.
Source:
Returns:
The object with traversed properties. Unlike the JSON reviver, this won't delete null members.
Type
Object