Files

14 lines
490 B
TypeScript
Raw Permalink Normal View History

2026-10-11 22:11:08 -04:00
// The API returns a NullResource for any include the viewer lacks permission for.
2026-10-05 18:10:18 -04:00
interface NullResourceLike {
object: 'null_resource';
}
export function relationshipData<T>(relationship: { data: T[] } | NullResourceLike | undefined): T[] {
return relationship && 'data' in relationship ? relationship.data : [];
}
export function relationshipAttributes<A>(relationship: { attributes: A | null } | undefined): A | undefined {
return relationship?.attributes ?? undefined;
}