ParentReferences

Utilities for working with parent references.

Parent references are used to keep track of a resource's parents, such as which topics a drop belongs to. See the ParentReference interface for more details.

Returns all parent references of the given type from the provided parent references.

ParentReferences.get(type: string, references: ParentReference[]): ParentReference[]
ArgumentTypeDescription
type*stringThe type of parent for which to get the references.
references*ParentReference[]The parent references from which to get.

Returns the IDs of all the parents of the given type from the provided parent references.

ParentReferences.getIds(type: string, references: ParentReference[]): string[]
ArgumentTypeDescription
type*stringThe type of parent for which to get the IDs.
references*ParentReference[]The parent references from which to get the IDs.

Checks whether the provided parent references contain one or more references of the given type.

ParentReferences.contains(type: string, references: ParentReference[]): boolean
ArgumentTypeDescription
type*stringThe type of parent to check for.
references*ParentReference[]The parent references in which to check.

Generates a parent reference given a parent type and ID.

ParentReferences.generate(type: string, id: string): ParentReference
ArgumentTypeDescription
type*stringThe parent type.
id*stringThe parent ID.

Validates parents references, checking that they have valid type and id properties, and no other properties.

Throws a ParentReferenceValidationError if the validation fails.

ParentReferences.validate(references: ParentReference[]): void
ArgumentTypeDescription
references*ParentReference[]The parent references to validate.