Module: version-map-query

System-internal version maps for versioned objects are CSV files with LF (Unix style newline) line endings and comma-separated pairs of timestamp (left-padded with "0"s to always use 16 characters), object-hash. All object hashes in a given version map are versions of the same ID object.

Since we only append to the file the latest version can be found at the very end, and the order is a chronological log of version creation.

Format:

timestamp,objectHash
timestamp,objectHash
timestamp,objectHash
...

The timestamp is the time when the version map entry was made.

Source:

Methods

(async, static) getNthVersionMapHash(idHash, indexopt) → {Promise.<SHA256Hash>}

Parameters:
Name Type Attributes Default Description
idHash SHA256IdHash

The filename of the map to be loaded, which is the ID hash of a versioned object

index number <optional>
-1

The zero-based integer index (0, 1,...) in the version map from which the object hash should be returned. If the index is negative the count starts at the end of the list of versions. For example, to get the latest entry you can use an index of -1, or -2 for the last but one, etc. If no index is given the default is -1 for the latest version.

Source:
Returns:

Returns a promise resolving with the SHA-256 object hash stored for the given index

Type: Promise.<SHA256Hash>

(async, static) getNthVersionMapEntry(idHash, indexopt) → {Promise.<VersionMapEntry>}

Parameters:
Name Type Attributes Default Description
idHash SHA256IdHash

The filename of the map to be loaded, which is the ID hash of a versioned object

index number <optional>
-1

The zero-based integer index (0, 1,...) in the version map from which the object hash should be returned. If the index is negative the count starts at the end of the list of versions. For example, to get the latest entry you can use an index of -1, or -2 for the last but one, etc. If no index is given the default is -1 for the latest version.

Source:
Returns:

Returns a VersionMapEntry object

Type: Promise.<VersionMapEntry>

(async, static) getAllVersionMapEntries(idHash) → {Promise.<Array.<VersionMapEntry>>}

Parameters:
Name Type Description
idHash SHA256IdHash

The filename of the map to be loaded, which is the ID hash of a versioned object

Reads the version map with the given ID hash

Source:
Returns:

Returns a promise resolving with an array of VersionMapEntry objects

Type: Promise.<Array.<VersionMapEntry>>

(async, static) getTimestampForHash(idHash, hash) → {Promise.<(number|undefined)>}

Parameters:
Name Type Description
idHash SHA256IdHash

The filename of the map to be loaded, which is the ID hash of a versioned object

hash SHA256Hash

The hash under the given ID hash for which the creation timestamp should be returned.

Reads the version map with the given ID hash

Source:
Returns:

Returns a promise resolving with the timestamp of the given hash under the given ID hash, or undefined if no entry was found for the given hash in the given version map identified by the given ID hash.

Type: Promise.<(number|undefined)>

(async, static) listVersionsByIdObj(obj) → {Promise.<Array.<VersionMapEntry>>}

Parameters:
Name Type Description
obj OneVersionedObjectTypes

A versioned ONE object which is used to create its ID hash. Note that it does not have to be an ID object, i.e. it can have more properties than just ID properties, they will be ignored.

Frontend for getAllVersionMapEntries that accepts an ID object and calculates its crypto hash before calling that function. This function allows to retrieve a list of available versions for a given object ID. It returns an array of numbers (dates in milliseconds since 1/1/1970) and object hashes which can then be used to retrieve a specific version.

Source:
Returns:

An array of VersionMapEntry objects

Type: Promise.<Array.<VersionMapEntry>>