(key: string)
| 577 | * `knowledge-base` context. |
| 578 | */ |
| 579 | export function inferContextFromKey(key: string): StorageContext { |
| 580 | if (!key) { |
| 581 | throw new Error('Cannot infer context from empty key') |
| 582 | } |
| 583 | |
| 584 | if (key.startsWith('kb/') || key.startsWith('knowledge-base/')) return 'knowledge-base' |
| 585 | if (key.startsWith('chat/')) return 'chat' |
| 586 | if (key.startsWith('copilot/')) return 'copilot' |
| 587 | if (key.startsWith('execution/')) return 'execution' |
| 588 | if (key.startsWith('workspace/')) return 'workspace' |
| 589 | if (key.startsWith('profile-pictures/')) return 'profile-pictures' |
| 590 | if (key.startsWith('og-images/')) return 'og-images' |
| 591 | if (key.startsWith('workspace-logos/')) return 'workspace-logos' |
| 592 | if (key.startsWith('logs/')) return 'logs' |
| 593 | |
| 594 | throw new Error( |
| 595 | `File key must start with a context prefix (kb/, knowledge-base/, chat/, copilot/, execution/, workspace/, profile-pictures/, og-images/, workspace-logos/, or logs/). Got: ${key}` |
| 596 | ) |
| 597 | } |
| 598 | |
| 599 | /** |
| 600 | * Extract storage key and context from an internal file URL |
no outgoing calls
no test coverage detected