import { n as BuildingAttributeKey, l as AuthOptions, k as AssetsApi, aQ as UploadOptions, d as AssetHandle, aH as PlacementInput, g as AssetListParams, h as AssetListResult, a as MDSMap } from '../map-B04kt8ZG.cjs'; /** * Types của tầng TRANSPORT cho API xử lý nội dung 3D, do SDK tự khai. * * Bản khai này cố ý độc lập, không dẫn về khai báo nào bên ngoài, để public * `.d.ts` tự chứa. Tính tương thích được gate bằng test hợp đồng trong CI. * * Đây KHÔNG phải public surface — bề mặt dành cho người dùng là facade trong * `assets.ts`. * * Ghi chú riêng tư: file này đi vào gói phát hành công khai. Đừng dẫn đường * dẫn mã nguồn backend, tên service nội bộ hay mô tả lỗi của hệ thống vào * đây — mô tả HỢP ĐỒNG (client nhìn thấy gì, phải phòng gì), không mô tả * cách backend hiện thực. `scripts/check-dist-privacy.mjs` chặn phần lớn, * nhưng câu chữ thì nó không đọc hộ được. */ type ProcessingAssetStatus = 'uploaded' | 'processing' | 'ready' | 'failed'; type ProcessingJobMode = 'build' | 'rebuild_from_geojson' | 'publish'; /** State machine job — KHÔNG có `cancelling`. */ type ProcessingJobState = 'queued' | 'leased' | 'running' | 'succeeded' | 'failed' | 'cancelled'; type ProcessingStageState = 'pending' | 'running' | 'succeeded' | 'failed' | 'skipped'; interface ProcessingJobStage { name: string; state: ProcessingStageState; progress: number; startedAt: string | null; finishedAt: string | null; message: string | null; } interface ProcessingJobError { code: string; message: string; } interface ProcessingJob { id: string; assetId: string; mode: ProcessingJobMode; state: ProcessingJobState; cancelRequestedAt: string | null; currentStage: string | null; stages: ProcessingJobStage[]; error: ProcessingJobError | null; publicationId: string | null; attempt: number; maxAttempts: number; createdAt: string; startedAt: string | null; finishedAt: string | null; } interface ProcessingAsset { id: string; name: string; originalFilename: string; sizeBytes: number; status: ProcessingAssetStatus; latestJob: ProcessingJob | null; activePublicationId: string | null; createdAt: string; updatedAt: string; } interface ProcessingAssetListResponse { items: ProcessingAsset[]; total: number; page: number; pageSize: number; } interface ProcessingUploadResponse { asset: ProcessingAsset; job: ProcessingJob; } interface ProcessingCancelJobResponse { state: ProcessingJobState; cancelRequestedAt: string | null; } interface ProcessingOffsetEnu { east: number; north: number; up: number; } interface ProcessingCreatePlacementRequest { anchorLat: number; anchorLon: number; heightM?: number; headingDeg?: number; pitchDeg?: number; rollDeg?: number; scale?: number; offsetEnu?: ProcessingOffsetEnu; confirmed?: boolean; } interface ProcessingPlacementRevision { id: string; assetId: string; anchorLat: number; anchorLon: number; heightM: number; headingDeg: number; pitchDeg: number; rollDeg: number; scale: number; offsetEnu?: ProcessingOffsetEnu; confirmed: boolean; /** * 16 double COLUMN-MAJOR — ma trận gốc của revision này. * * CẢNH BÁO: kiểu khai báo KHÔNG diễn đạt hết thực tế. Trường có thể về * client là mảng RỖNG — không phải `null`, cũng không phải đủ 16 số — với * revision chưa dựng xong. Mọi nơi tiêu thụ phải kiểm * `length === 16 && mọi phần tử hữu hạn` trước khi dùng, và dựng lại bằng * `rootTransform(toPlacementMathParams(...))` khi không đạt. */ rootTransform: number[]; draftTilesetUrl: string | null; createdAt: string; } type ProcessingPublicationStatus = 'building' | 'ready' | 'failed'; interface ProcessingPublication { id: string; assetId: string; version: number; status: ProcessingPublicationStatus; active: boolean; jobId: string | null; placementRevisionId: string | null; tilesetUrl: string; featureCount: number | null; createdAt: string; } interface ProcessingCreatePublicationResponse { publication: ProcessingPublication; job: ProcessingJob; } interface ProcessingFeatureMapItem { publishedFeatureId: number; buildingId: string; } interface ProcessingFeatureMapResponse { items: ProcessingFeatureMapItem[]; } /** Một công trình trong danh sách build (subset của `BuildingItem` contract §3). */ interface ProcessingBuildingListItem { buildingId: string; /** Feature id trong draft GLB (`_FEATURE_ID_0`) — contract v2.2 §10.3. */ draftFeatureId: number | null; } /** Response `GET /api/v1/assets/{assetId}/buildings` (subset). */ interface ProcessingBuildingListResponse { items: ProcessingBuildingListItem[]; } type ProcessingAttributeSource = 'auto' | 'manual'; interface ProcessingAttributeField { value: string | number | null; source: ProcessingAttributeSource; } interface ProcessingBuildingAttributesResponse { version: number; fields: Partial>; updatedAt: string | null; } interface ProcessingUpdateAttributesRequest { baseVersion: number; /** Chỉ 10 key hợp lệ — chặn gửi key rác từ compile-time (audit P3.1). */ attributes: Partial>; } /** Body lỗi chuẩn của processing API: `{ error: { code, message, detail? } }`. */ interface ProcessingApiErrorBody { error?: { code?: string; message?: string; detail?: Record; }; } /** * Tầng vận chuyển HTTP của phần assets — BROWSER-NATIVE, KHÔNG axios. * * - Request JSON (GET/POST/PUT) đi qua `fetch`. * - Upload `FormData` cần tiến độ đi qua `XMLHttpRequest` (`fetch` chưa có * upload progress ở mọi trình duyệt mục tiêu). * * Mọi lỗi ném ra khỏi module này đều là `MDSMapError` — tầng trên không bao * giờ thấy `Response`, `ProgressEvent` hay `DOMException` thô. */ /** Tham số query — `undefined` bị bỏ qua khi dựng URL. */ type QueryParams = Record; /** Tuỳ chọn chung của một request. */ interface RequestOptions { query?: QueryParams; signal?: AbortSignal; } /** Tuỳ chọn upload FormData. */ interface UploadRequestOptions { /** Tiến độ truyền file 0–100 (chỉ bắn khi trình duyệt biết tổng số byte). */ onProgress?: (percent: number) => void; signal?: AbortSignal; } /** Cấu hình khởi tạo transport. */ interface TransportOptions { /** `MapOptions.baseUrl`. Bỏ trống → lấy origin của trang hiện tại. */ baseUrl?: string; auth?: AuthOptions; } /** * Client HTTP dùng chung cho `AssetManager` và `AssetContentResolver`. * * Vòng đời auth: KHÔNG cache token — mỗi request gọi lại `getAccessToken()` * đúng theo hợp đồng `AuthOptions`. Gặp 401 thì thử lại ĐÚNG MỘT lần (lấy * token mới) rồi mới báo `MDS_AUTH_FAILED`. */ declare class Transport { #private; readonly baseUrl: string; constructor(options?: TransportOptions); /** URL tuyệt đối cho một artifact/tileset backend trả về (audit P2.4). */ absolutize(path: string): string; /** URL tuyệt đối của một endpoint nghiệp vụ (`/assets` → `/api/v1/assets`). */ endpoint(path: string, query?: QueryParams): string; get(path: string, options?: RequestOptions): Promise; post(path: string, body?: unknown, options?: RequestOptions): Promise; put(path: string, body: unknown, options?: RequestOptions): Promise; /** * Header xác thực cho MỘT request. * * - `token`: gọi `getAccessToken()` mỗi lần (không cache). * - `apiKey`: cùng header `Authorization: Bearer `. * - không cấu hình: không gửi header nào. */ authHeaders(): Promise>; /** * Upload `FormData` qua `XMLHttpRequest` để có tiến độ truyền byte. * 401 cũng được thử lại đúng một lần như đường `fetch`. */ upload(path: string, createForm: () => FormData, options?: UploadRequestOptions): Promise; } /** * `AssetsApi` + `AssetHandle` — facade quản trị nội dung 3D của SDK. * * Người dùng SDK chỉ thấy vòng đời `uploading → processing → ready → published`; * bên dưới là chuỗi endpoint của processing API (upload → job build → placement * revision → publication → activate → feature-map). * * BẤT BIẾN VỀ RACE (async state machine): * - Mỗi asset chỉ có ĐÚNG MỘT `AssetHandle` trong một `AssetManager` và ĐÚNG * MỘT vòng poll (`#watch`) — gọi `get()`/`upload()` nhiều lần không nhân đôi * request. * - `waitUntilReady()` gọi bao nhiêu lần cũng chia sẻ một vòng poll; mọi waiter * được settle đúng một lần qua `#settle()`. * - `publish()` không cho hai lượt chạy song song trên cùng asset (xem docs * của method). */ /** Tuỳ chọn khởi tạo `AssetManager`. */ interface AssetManagerOptions extends TransportOptions { /** * Nhịp poll (ms). Mặc định `POLL_INTERVAL_MS` = 2000. * @internal chỉ để test rút ngắn thời gian chạy. */ pollIntervalMs?: number; /** * Dùng lại `Transport` có sẵn để chia sẻ auth/baseUrl với * `AssetContentResolver` (chỉ một nơi giữ cấu hình). Có giá trị thì * `baseUrl`/`auth` bị bỏ qua. */ transport?: Transport; } /** * Hiện thực `AssetsApi` trên processing API của MDS. * * Một instance quản lý một tập handle (một handle / assetId) và dùng chung * `Transport` với `AssetContentResolver` để chỉ có một nơi giữ auth + baseUrl. */ declare class AssetManager implements AssetsApi { #private; readonly transport: Transport; constructor(options?: AssetManagerOptions); /** * Upload GLB. Kiểm tra đuôi file + kích thước NGAY tại client (không tốn * băng thông cho file chắc chắn bị từ chối), rồi POST multipart với tiến độ. */ upload(file: File | Blob, options?: UploadOptions): Promise; get(assetId: string): Promise; /** * Tạo placement revision nháp cho một asset — hiện thực của `AssetDraftPort` * (`core/widget-ports.ts`) mà `createMap` chuyển cho widget xem trước. * * Đi qua handle trong sổ (nếu có) chứ không gọi thẳng transport, để request * nháp cũng bị cắt khi `map.destroy()` / `disposeAll()` chạy. */ createPlacementDraft(assetId: string, placement: PlacementInput, options?: { signal?: AbortSignal; }): Promise; list(params?: AssetListParams): Promise; /** * Dừng theo dõi MỌI handle đang giữ (I1 — B3). * * `map.destroy()` phải cắt được mọi vòng poll 2 giây còn treo; không có bước * này thì một SPA điều hướng qua lại sẽ tích luỹ vòng poll của các map đã * chết và tiếp tục gọi API mãi mãi. * * Idempotent: gọi lại là no-op (sổ đã rỗng, `AssetHandle.dispose()` cũng * idempotent). Handle mà người dùng SDK còn giữ vẫn đọc được `status`/ * `progress` cuối cùng — chỉ phần theo dõi dừng lại và `waitUntilReady()` * đang chờ bị reject `MDS_CANCELLED`. */ disposeAll(): void; } /** * Entry NỘI BỘ cho các ứng dụng MDS (digitwin) — `@dgtwin/map3d/internal`. * * ⚠️ KHÔNG có trong tài liệu công khai và KHÔNG cam kết ổn định: mọi thứ ở đây * có thể đổi/biến mất trong bất kỳ bản phát hành nào, kể cả patch. Chỉ dùng * trong ứng dụng của MDS, nơi SDK và app lên phiên bản cùng nhau. Đội ngoài * dùng `@dgtwin/map3d` và `@dgtwin/map3d/react`. * * Types tầng transport (SDK-owned, self-contained) export tại đây cho tooling * nội bộ; KHÔNG re-export từ public entry. */ /** * Viewer thô của engine 3D bên dưới một map. * * @internal KHÔNG ỔN ĐỊNH. Trả `unknown` CÓ CHỦ ĐÍCH: kiểu thật là * `Cesium.Viewer`, nhưng lộ kiểu đó ra `.d.ts` công khai sẽ (a) biến `cesium` * thành dependency mà người dùng phải cài — điều cả SDK dựng lên để tránh, và * (b) làm `check-public-dts` đỏ. Bên gọi tự ép kiểu: * * ```ts * import { getEngineViewer } from '@dgtwin/map3d/internal'; * * // `Viewer` lấy từ package engine mà CHÍNH APP cài (SDK không lộ kiểu này). * const viewer = getEngineViewer(map) as Viewer; * ``` * * Ép kiểu như trên chỉ hợp lệ khi app dùng ĐÚNG phiên bản Cesium mà SDK bundle. * Đụng thẳng vào viewer là đi vòng qua mọi bất biến của SDK (vòng đời layer, * `requestRenderMode`, dọn dẹp khi destroy) — tự chịu trách nhiệm. * * @throws MDSMapError `MDS_DESTROYED` nếu map đã `destroy()`. * @throws MDSMapError `MDS_NOT_IMPLEMENTED` nếu không lần được tới viewer * (map giả trong test, engine đổi cấu trúc nội bộ, hoặc engine chưa init). */ declare function getEngineViewer(map: MDSMap): unknown; export { AssetManager, type AssetManagerOptions, type ProcessingApiErrorBody, type ProcessingAsset, type ProcessingAssetListResponse, type ProcessingAssetStatus, type ProcessingAttributeField, type ProcessingAttributeSource, type ProcessingBuildingAttributesResponse, type ProcessingBuildingListItem, type ProcessingBuildingListResponse, type ProcessingCancelJobResponse, type ProcessingCreatePlacementRequest, type ProcessingCreatePublicationResponse, type ProcessingFeatureMapItem, type ProcessingFeatureMapResponse, type ProcessingJob, type ProcessingJobError, type ProcessingJobMode, type ProcessingJobStage, type ProcessingJobState, type ProcessingOffsetEnu, type ProcessingPlacementRevision, type ProcessingPublication, type ProcessingPublicationStatus, type ProcessingStageState, type ProcessingUpdateAttributesRequest, type ProcessingUploadResponse, getEngineViewer };