blob: 108489bf833f3d32f63e4ba9b762b6a654fe7bc8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import type { ProjectRecord } from "./types";
export function isRecord(value: unknown): value is ProjectRecord {
return typeof value === "object" && value !== null;
}
export function getProjectId({
project,
}: {
project: ProjectRecord;
}): string | null {
const idValue = project.id;
if (typeof idValue === "string" && idValue.length > 0) {
return idValue;
}
const metadataValue = project.metadata;
if (!isRecord(metadataValue)) {
return null;
}
const metadataId = metadataValue.id;
if (typeof metadataId === "string" && metadataId.length > 0) {
return metadataId;
}
return null;
}
|