mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 09:26:42 +02:00
fix(types): resolve TypeScript errors across multiple packages
- bot-services: Add registerAsync to AI, Calendar, Clock, Todo modules - bot-services: Add convenience methods to ClockService for bot handlers - bot-services: Make CreateEventInput.endTime optional with sensible defaults - bot-services: Fix empty interface ESLint errors (use type aliases) - questions-backend: Add missing schema columns (isDefault, sortOrder, deletedAt) - questions-backend: Fix or() return type handling in question service - questions-web: Add guard for undefined question ID in route params - skilltree-web: Fix DBSchema type by not extending idb interface directly - calendar-web: Fix Check icon prop (use weight instead of strokeWidth) - matrix-mana-bot: Update clock handler to use new service methods Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
91143a497b
commit
1733580d05
14 changed files with 314 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Module, DynamicModule } from '@nestjs/common';
|
||||
import { Module, DynamicModule, Provider, Type, ModuleMetadata } from '@nestjs/common';
|
||||
import { TodoService, TODO_STORAGE_PROVIDER } from './todo.service';
|
||||
import { StorageProvider } from '../shared/types';
|
||||
import { FileStorageProvider } from '../shared/storage';
|
||||
|
|
@ -9,6 +9,11 @@ export interface TodoModuleOptions {
|
|||
storageProvider?: StorageProvider<TodoData>;
|
||||
}
|
||||
|
||||
export interface TodoModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
||||
useFactory: (...args: unknown[]) => Promise<TodoModuleOptions> | TodoModuleOptions;
|
||||
inject?: (Type<unknown> | string | symbol)[];
|
||||
}
|
||||
|
||||
@Module({})
|
||||
export class TodoModule {
|
||||
/**
|
||||
|
|
@ -23,7 +28,8 @@ export class TodoModule {
|
|||
providers: [
|
||||
{
|
||||
provide: TODO_STORAGE_PROVIDER,
|
||||
useValue: options?.storageProvider ?? new FileStorageProvider<TodoData>(storagePath, defaultData),
|
||||
useValue:
|
||||
options?.storageProvider ?? new FileStorageProvider<TodoData>(storagePath, defaultData),
|
||||
},
|
||||
TodoService,
|
||||
],
|
||||
|
|
@ -47,4 +53,30 @@ export class TodoModule {
|
|||
exports: [TodoService],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Register asynchronously with factory function
|
||||
*/
|
||||
static registerAsync(options: TodoModuleAsyncOptions): DynamicModule {
|
||||
const storageProvider: Provider = {
|
||||
provide: TODO_STORAGE_PROVIDER,
|
||||
useFactory: async (...args: unknown[]) => {
|
||||
const moduleOptions = await options.useFactory(...args);
|
||||
const storagePath = moduleOptions?.storagePath ?? './data/todo-data.json';
|
||||
const defaultData: TodoData = { tasks: [], projects: [] };
|
||||
return (
|
||||
moduleOptions?.storageProvider ??
|
||||
new FileStorageProvider<TodoData>(storagePath, defaultData)
|
||||
);
|
||||
},
|
||||
inject: options.inject || [],
|
||||
};
|
||||
|
||||
return {
|
||||
module: TodoModule,
|
||||
imports: options.imports || [],
|
||||
providers: [storageProvider, TodoService],
|
||||
exports: [TodoService],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue