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[]
Argument | Type | Description |
---|---|---|
type* | string | The 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[]
Argument | Type | Description |
---|---|---|
type* | string | The 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
Argument | Type | Description |
---|---|---|
type* | string | The 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
Argument | Type | Description |
---|---|---|
type* | string | The parent type. |
id* | string | The 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
Argument | Type | Description |
---|---|---|
references* | ParentReference[] | The parent references to validate. |