UNPKG

digitaltwin-core

Version:

Minimalist framework to collect and handle data in a Digital Twin project

125 lines 4.06 kB
import { AssetsManager } from './assets_manager.js'; import type { DataResponse } from './types.js'; import type { OpenAPIComponentSpec } from '../openapi/types.js'; import type { HttpMethod } from '../engine/endpoints.js'; import type { AsyncUploadable } from './async_upload.js'; import type { Queue } from 'bullmq'; /** * Metadata stored in database for a tileset. * Simplified: Cesium accesses files directly from OVH. */ export interface TilesetMetadataRow { id?: number; name: string; type: string; /** Base path in storage for deletion (e.g., tilesets/123) */ url: string; /** Public URL to tileset.json */ tileset_url: string; date: Date; description: string; filename: string; owner_id: number | null; is_public?: boolean; upload_status?: 'pending' | 'processing' | 'completed' | 'failed'; upload_job_id?: string; upload_error?: string; } /** * Specialized Assets Manager for handling 3D Tiles tilesets. * * This manager extracts uploaded ZIP files and stores each file in cloud storage (OVH S3), * allowing Cesium and other 3D viewers to load tilesets directly via public URLs. * * ## How it works * * 1. User uploads a ZIP containing a 3D Tiles tileset * 2. ZIP is extracted and all files are stored in OVH with public-read ACL * 3. Database stores only the tileset.json URL and base path * 4. Cesium loads tileset.json directly from OVH * 5. Cesium fetches tiles using relative paths in tileset.json (directly from OVH) * * ## Endpoints * * - GET /{endpoint} - List all tilesets with their public URLs * - POST /{endpoint} - Upload tileset ZIP (sync < 50MB, async >= 50MB) * - GET /{endpoint}/:id/status - Poll async upload status * - PUT /{endpoint}/:id - Update tileset metadata * - DELETE /{endpoint}/:id - Delete tileset and all files from storage * * @example * ```typescript * class MyTilesetManager extends TilesetManager { * getConfiguration() { * return { * name: 'tilesets', * description: 'Manage 3D Tiles tilesets', * contentType: 'application/json', * endpoint: 'api/tilesets', * extension: '.zip' * } * } * } * * // After upload, response contains: * // { tileset_url: 'https://bucket.s3.../tilesets/123/tileset.json' } * // * // Cesium loads directly: * // Cesium.Cesium3DTileset.fromUrl(tileset_url) * ``` */ export declare abstract class TilesetManager extends AssetsManager implements AsyncUploadable { /** Upload queue for async processing (injected by engine) */ protected uploadQueue: Queue | null; /** * Set the upload queue for async job processing. * Called by DigitalTwinEngine during initialization. */ setUploadQueue(queue: Queue): void; /** * Handle tileset upload. * * - Files < 50MB: Synchronous extraction and upload * - Files >= 50MB: Queued for async processing (returns 202) */ handleUpload(req: any): Promise<DataResponse>; /** * Authenticate user from request headers. * Returns user ID on success, or error response on failure. */ private authenticateUser; /** * Queue upload for background processing. Returns HTTP 202 immediately. */ private handleAsyncUpload; /** * Process upload synchronously. */ private handleSyncUpload; /** * Get upload status for async uploads. */ handleGetStatus(req: any): Promise<DataResponse>; /** * List all tilesets with their public URLs. */ retrieve(req?: any): Promise<DataResponse>; /** * Delete tileset and all files from storage. */ handleDelete(req: any): Promise<DataResponse>; /** * Get HTTP endpoints for this manager. */ getEndpoints(): Array<{ method: HttpMethod; path: string; handler: (...args: any[]) => any; responseType?: string; }>; /** * Generate OpenAPI specification. */ getOpenAPISpec(): OpenAPIComponentSpec; } //# sourceMappingURL=tileset_manager.d.ts.map