diff --git a/packages/tm-core/src/storage/api-storage.ts b/packages/tm-core/src/storage/api-storage.ts index b6651da1..0798e38e 100644 --- a/packages/tm-core/src/storage/api-storage.ts +++ b/packages/tm-core/src/storage/api-storage.ts @@ -37,6 +37,13 @@ export interface ApiStorageConfig { maxRetries?: number; } +/** + * Auth context with a guaranteed briefId + */ +type ContextWithBrief = NonNullable< + ReturnType +> & { briefId: string }; + /** * ApiStorage implementation using repository pattern * Provides flexibility to swap between different backend implementations @@ -767,7 +774,7 @@ export class ApiStorage implements IStorage { * Ensure a brief is selected in the current context * @returns The current auth context with a valid briefId */ - private ensureBriefSelected(operation: string) { + private ensureBriefSelected(operation: string): ContextWithBrief { const authManager = AuthManager.getInstance(); const context = authManager.getContext(); @@ -783,7 +790,7 @@ export class ApiStorage implements IStorage { ); } - return context; + return context as ContextWithBrief; } /**