MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / getTaskCardPropertyValue

Function getTaskCardPropertyValue

src/ui/taskCardPropertyAccess.ts:86–183  ·  view source on GitHub ↗
(
	task: TaskInfo,
	propertyId: string,
	context: TaskCardPropertyAccessContext
)

Source from the content-addressed store, hash-verified

84}
85
86export function getTaskCardPropertyValue(
87 task: TaskInfo,
88 propertyId: string,
89 context: TaskCardPropertyAccessContext
90): unknown {
91 try {
92 const mappingKey = context.fieldMapper.lookupMappingKey(propertyId);
93 if (mappingKey && hasPropertyExtractor(mappingKey)) {
94 return getPropertyExtractorValue(task, mappingKey);
95 }
96
97 if (hasPropertyExtractor(propertyId)) {
98 return getPropertyExtractorValue(task, propertyId);
99 }
100
101 if (propertyId.startsWith("user:")) {
102 return getUserPropertyValue(task, propertyId, context);
103 }
104
105 if (task.customProperties && propertyId in task.customProperties) {
106 return extractBasesValue(task.customProperties[propertyId]);
107 }
108
109 if (task.customProperties) {
110 const filePropertyId = `file.${propertyId}`;
111 if (filePropertyId in task.customProperties) {
112 return extractBasesValue(task.customProperties[filePropertyId]);
113 }
114 }
115
116 if (propertyId.startsWith("file.")) {
117 const basesData = getBasesDataGetter(task.basesData);
118 if (basesData) {
119 try {
120 const value = basesData.getValue(propertyId);
121 if (value !== null && value !== undefined) {
122 return extractBasesValue(value);
123 }
124 } catch {
125 // Bases property missing.
126 }
127 }
128 }
129
130 if (propertyId.startsWith("formula.")) {
131 try {
132 const basesData = getBasesDataGetter(task.basesData);
133 if (!basesData) {
134 return "";
135 }
136
137 const value = basesData.getValue(propertyId);
138 if (value === null || value === undefined) {
139 return "";
140 }
141
142 const extracted = extractBasesValue(value);
143 return extracted !== "" ? extracted : "";

Callers 2

renderPropertyMetadataFunction · 0.85

Calls 10

extractBasesValueFunction · 0.90
hasPropertyExtractorFunction · 0.85
getUserPropertyValueFunction · 0.85
getBasesDataGetterFunction · 0.85
lookupMappingKeyMethod · 0.80
debugMethod · 0.80
warnMethod · 0.80
getFrontmatterValueFunction · 0.70
getValueMethod · 0.45

Tested by

no test coverage detected