(value: unknown, path: string, depth: number)
| 184 | const omissions: { path: string; kind: string; count: number }[] = []; |
| 185 | let budget = 16_000; |
| 186 | const copy = (value: unknown, path: string, depth: number): unknown => { |
| 187 | if (value === undefined) return undefined; |
| 188 | if (budget <= 0 || depth > 10) { |
| 189 | omissions.push({ path, kind: 'value', count: 1 }); return null; |
| 190 | } |
| 191 | if (typeof value === 'string') { |
| 192 | const limit = Math.max(0, Math.min(1200, budget)); |
| 193 | budget -= Math.min(value.length, limit); |
| 194 | if (value.length > limit) omissions.push({ path, kind: 'characters', count: value.length - limit }); |
| 195 | return value.slice(0, limit); |
| 196 | } |
| 197 | if (value === null || typeof value !== 'object') { budget -= 16; return value; } |
| 198 | if (Array.isArray(value)) { |
| 199 | const result: unknown[] = []; |
| 200 | for (let i = 0; i < Math.min(value.length, 24) && budget > 0; i++) result.push(copy(value[i], `${path}[${i}]`, depth + 1)); |
| 201 | if (result.length < value.length) omissions.push({ path, kind: 'items', count: value.length - result.length }); |
| 202 | return result; |
| 203 | } |
| 204 | const entries = Object.entries(value), result: Record<string, unknown> = {}; |
| 205 | let processed = 0; |
| 206 | for (const [key, item] of entries) { |
| 207 | if (processed >= 48 || budget <= 0) break; |
| 208 | budget -= key.length + 6; processed++; |
| 209 | result[key] = copy(item, `${path}.${key}`, depth + 1); |
| 210 | } |
| 211 | if (processed < entries.length) omissions.push({ path, kind: 'fields', count: entries.length - processed }); |
| 212 | return result; |
| 213 | }; |
| 214 | // Keep provenance and limits ahead of potentially large member collections. In |
| 215 | // Architecture the connections of a part say more than the members listed with it. |
| 216 | const head = { kind: 'current-selection-evidence', project: evidence.project, view: evidence.view, |
no test coverage detected