MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / extractBasesValue

Function extractBasesValue

src/ui/taskCardPresentation.ts:99–142  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

97 * returned intact so TaskCard can render them with Value.renderTo().
98 */
99export function extractBasesValue(value: unknown): unknown {
100 if (isNullBasesValue(value)) {
101 return "";
102 }
103
104 if (isBasesValue(value)) {
105 return value;
106 }
107
108 if (value && typeof value === "object" && "icon" in value) {
109 const v = value as Record<string, unknown>;
110
111 if (v.icon === "lucide-link" && "data" in v && v.data !== null && v.data !== undefined) {
112 const linkPath = stringifyUnknown(v.data);
113 if (!linkPath.match(/^[a-z]+:\/\//i)) {
114 const display = "display" in v && v.display ? stringifyUnknown(v.display) : null;
115 if (display && display !== linkPath) {
116 return `[[${linkPath}|${display}]]`;
117 }
118 return `[[${linkPath}]]`;
119 }
120 const display = "display" in v && v.display ? stringifyUnknown(v.display) : null;
121 if (display) {
122 return `[${display}](${linkPath})`;
123 }
124 return linkPath;
125 }
126
127 if ("display" in v && v.display !== null && v.display !== undefined) {
128 return v.display;
129 }
130 if ("date" in v && v.date !== null && v.date !== undefined) {
131 return v.date;
132 }
133 if ("data" in v && v.data !== null && v.data !== undefined) {
134 return v.data;
135 }
136 if (v.icon === "lucide-file-question" || v.icon === "lucide-help-circle") {
137 return "";
138 }
139 return v.icon ? stringifyUnknown(v.icon).replace("lucide-", "") : "";
140 }
141 return value;
142}
143
144export function resolveTaskCardPropertyLabel(
145 propertyId: string,

Calls 3

stringifyUnknownFunction · 0.90
isNullBasesValueFunction · 0.85
isBasesValueFunction · 0.85

Tested by

no test coverage detected