mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
7283b75cac
A read tool that answers one list a page at a time (100 by default, up to 500) as compact one-line JSON rows, filtered by status, label or "no label", with the list's labels, the matching total and a cursor. The cursor is the last place's position (sort_order, created_at, id), so labelling a page while paging through unlabelled places skips none. getCollection orders by the same keys, id last, so both tools agree on ties.
93 lines
4.0 KiB
TypeScript
93 lines
4.0 KiB
TypeScript
import { Categories } from '../../db/entities/Categories.entity';
|
|
import { CollectionLabels } from '../../db/entities/CollectionLabels.entity';
|
|
import { CollectionMembers } from '../../db/entities/CollectionMembers.entity';
|
|
import { CollectionPlaceRatings } from '../../db/entities/CollectionPlaceRatings.entity';
|
|
import { CollectionPlaces } from '../../db/entities/CollectionPlaces.entity';
|
|
import { Collections } from '../../db/entities/Collections.entity';
|
|
import { PlaceRatings } from '../../db/entities/PlaceRatings.entity';
|
|
import { Places } from '../../db/entities/Places.entity';
|
|
import { Tags } from '../../db/entities/Tags.entity';
|
|
import { TripMembers } from '../../db/entities/TripMembers.entity';
|
|
import { Trips } from '../../db/entities/Trips.entity';
|
|
import { Users } from '../../db/entities/Users.entity';
|
|
import { PluginGuardsModule } from '../../nest-rpc/plugin-guards.module';
|
|
import { AddonsModule } from '../addons/addons.module';
|
|
import { AppConfigModule } from '../app-config/app-config.module';
|
|
import { McpSharedModule } from '../mcp-shared/mcp-shared.module';
|
|
import { NotificationsModule } from '../notifications/notifications.module';
|
|
import { PermissionsModule } from '../permissions/permissions.module';
|
|
import { PlaceImportModule } from '../place-import/place-import.module';
|
|
import { PlacesModule } from '../places/places.module';
|
|
import { buildStorageUploadOptions } from '../storage/storage-upload.factory';
|
|
import { StorageModule } from '../storage/storage.module';
|
|
import { StorageService } from '../storage/storage.service';
|
|
import { CollectionsItemsService } from './collections-items.service';
|
|
import { CollectionsPlacesPageService } from './collections-places-page.service';
|
|
import { CollectionsStorageRefsService } from './collections-storage-refs.service';
|
|
import { CollectionsController } from './collections.controller';
|
|
import { MAX_COVER_SIZE } from './collections.controller';
|
|
import { CollectionsMcp } from './collections.mcp';
|
|
import { CollectionsRpc } from './collections.rpc';
|
|
import { CollectionsService } from './collections.service';
|
|
import { MikroOrmModule } from '@mikro-orm/nestjs';
|
|
import { Module } from '@nestjs/common';
|
|
import { MulterModule } from '@nestjs/platform-express';
|
|
|
|
/** Collections domain (saved-places library). Registered in AppModule.
|
|
* Exports CollectionsService for in-container consumers (PluginsModule's
|
|
* RPC host deps factory). */
|
|
@Module({
|
|
imports: [
|
|
// Two upload routes, two categories: the per-file resolver routes each part
|
|
// to the right spool. Fieldname routing is exact — FileInterceptor('cover')/
|
|
// FileInterceptor('image') reject any other part with LIMIT_UNEXPECTED_FILE
|
|
// before the storage callbacks run. Both routes pass their fileFilter
|
|
// inline (cover keeps its plain-Error 500 quirk; image its statusCode 400).
|
|
MulterModule.registerAsync({
|
|
imports: [StorageModule],
|
|
inject: [StorageService],
|
|
useFactory: (storage: StorageService) =>
|
|
buildStorageUploadOptions(storage, {
|
|
category: (_req, file) => (file.fieldname === 'image' ? 'places' : 'covers'),
|
|
maxSize: MAX_COVER_SIZE, // same 20 MB cap for covers and place images
|
|
}),
|
|
}),
|
|
StorageModule,
|
|
NotificationsModule,
|
|
AddonsModule,
|
|
PermissionsModule,
|
|
AppConfigModule,
|
|
PluginGuardsModule,
|
|
PlaceImportModule,
|
|
// Copying saved places into a trip runs the places domain's journey hook, and
|
|
// the copy tool sends its place events the way every MCP tool does.
|
|
PlacesModule,
|
|
McpSharedModule,
|
|
MikroOrmModule.forFeature([
|
|
Collections,
|
|
CollectionMembers,
|
|
CollectionLabels,
|
|
CollectionPlaces,
|
|
CollectionPlaceRatings,
|
|
Categories,
|
|
Users,
|
|
Trips,
|
|
TripMembers,
|
|
Places,
|
|
PlaceRatings,
|
|
Tags,
|
|
]),
|
|
],
|
|
controllers: [CollectionsController],
|
|
providers: [
|
|
CollectionsService,
|
|
CollectionsItemsService,
|
|
CollectionsPlacesPageService,
|
|
CollectionsMcp,
|
|
CollectionsRpc,
|
|
CollectionsStorageRefsService,
|
|
],
|
|
exports: [CollectionsService],
|
|
})
|
|
export class CollectionsModule {}
|