Global

Methods

compareWithGoldenFile(pbObject, goldenFilePath) → {Promise.<boolean>}

Description:
  • Compare a Protocol Buffer object with a golden JSON file
Source:
Parameters:
Name Type Description
pbObject Object Protocol Buffer object to compare
goldenFilePath string Path to the golden JSON file
Returns:
Promise that resolves to true if the objects match
Type
Promise.<boolean>

createEmptyPhenopacketJson(schemaVersion) → {Object}

Description:
  • Create an empty phenopacket structure with required fields
Source:
Parameters:
Name Type Default Description
schemaVersion string v2 Schema version to use ("v1" or "v2")
Returns:
An empty phenopacket object with required fields
Type
Object

dateToTimestamp(date) → {Timestamp}

Description:
  • Convert a JavaScript Date to a Protocol Buffer Timestamp
Source:
Parameters:
Name Type Description
date Date JavaScript Date object
Returns:
Protocol Buffer Timestamp
Type
Timestamp

fromJSON(json, MessageType) → {Object}

Description:
  • Simplified utility for creating a Protocol Buffer object from a JSON object This only handles direct property assignments for simple cases For complex nested objects, manual conversion is recommended
Source:
Parameters:
Name Type Description
json string JSON string to convert
MessageType function Protocol Buffer message constructor (e.g., pps.v2.Phenopacket)
Returns:
Protocol Buffer object instance with basic properties set
Type
Object

getGetterMethods(pbObject) → {Array.<string>}

Description:
  • Helper function to get all available getter methods on a Protocol Buffer object
Source:
Parameters:
Name Type Description
pbObject Object Protocol Buffer object to inspect
Returns:
Array of getter method names
Type
Array.<string>

getSetterMethods(pbObject) → {Array.<string>}

Description:
  • Helper function to get all available setter methods on a Protocol Buffer object
Source:
Parameters:
Name Type Description
pbObject Object Protocol Buffer object to inspect
Returns:
Array of setter method names
Type
Array.<string>

jsonToPhenopacket(json, v2Classes) → {Object}

Description:
  • Convert JSON to a Phenopacket v2 object with proper handling of nested structures
Source:
Parameters:
Name Type Description
json string JSON string representation of a phenopacket
v2Classes Object Object containing v2 class constructors (optional)
Returns:
Fully populated Phenopacket object
Type
Object

phenopacketToJSON(phenopacket, options) → {string}

Description:
  • Specialized helper to convert a Phenopacket v2 to JSON This function handles the specific structure of Phenopackets
Source:
Parameters:
Name Type Description
phenopacket Object A v2 Phenopacket object
options Object Options for JSON conversion (same as toJSON)
Returns:
JSON representation of the phenopacket
Type
string

timestampToDate(timestamp) → {Date}

Description:
  • Convert a Protocol Buffer Timestamp to a JavaScript Date
Source:
Parameters:
Name Type Description
timestamp Timestamp Protocol Buffer Timestamp
Returns:
JavaScript Date object
Type
Date

toJSON(pbObject, options) → {string}

Description:
  • Convert a Protocol Buffer object to a JSON string
Source:
Parameters:
Name Type Description
pbObject Object Protocol Buffer object to convert
options Object Conversion options
Properties
Name Type Description
pretty boolean Whether to format the JSON with indentation (default: false)
useProtoFieldName boolean Whether to use protobuf field names (default: false)
Returns:
JSON string representation
Type
string

validateOntologyTerm(term, fieldPath) → {Object}

Description:
  • Validate an ontology term object
Source:
Parameters:
Name Type Description
term Object The ontology term to validate
fieldPath string Path to the field being validated (for error messages)
Returns:
Validation result with errors and warnings
Type
Object

validatePhenopacketJson(json, schemaVersion) → {Object}

Description:
  • Validate a JSON object against the Phenopacket schema
Source:
Parameters:
Name Type Default Description
json Object | string JSON object or string to validate
schemaVersion string v2 Schema version to validate against ("v1" or "v2")
Returns:
Validation result with isValid and errors properties
Type
Object