import { ComponentPayload } from './componentpayload'; import { OpenFileAsJsonAssetOptions } from '../functions/dataaccess'; import { ContentTypeItem, ContentTypeMaterial } from '../functions/contenttypes'; export type ResponseType = 'catalog' | 'components' | 'allItems' | 'materials' | 'textures' | 'allTags' | 'catalogElementAdditionalInfos'; /** * This class is responsible for getting local asset files for the project the user is working on. * This encapsulates the dataccess.js functions to provide easy by-id access to the files. * The files are cached in memory, so that they can be accessed quickly. * The get*ById function will return the respective files as JSONs (or undefined if not found). * On calling the access access functions, their files are checked for changes and reloaded if necessary. */ export declare class ProjectFileService { /** * Absolute path to the root of the project. * This is the folder where the CTSettings.contentFolderName folder is located. */ readonly projectRootPath: string; private cache; private constructor(); /** * Constructor for the ProjectFileService. * @returns undefined if the path does not exist */ static create(projectRootPath: string): ProjectFileService | undefined; /** * Retrieves a ComponentPayload for the given component ID. * * - Checks the in-memory cache first. * - If the file has changed since last access (based on timestamp), reloads it from disk. * - Caches the loaded payload for future requests. * * @param id The component ID to retrieve. * @returns The ComponentPayload instance, or undefined if the file does not exist or cannot be loaded. */ getComponentPayloadById(id: string): ComponentPayload | undefined; /** * Loads an item or material asset by ID and caches the result to avoid repeated disk access. * * If the caller provides `options`, the asset is normalized via `openFileAsJsonAsset` (e.g. ID/JSON configuration handling) before caching. * The cache is invalidated automatically when the file timestamp changes. * * @param id Catalog ID (catalog:external) of the asset to fetch. * @param type Whether the asset is an item or material. * @param options Optional overrides that influence ID filling and JSON configuration behaviour. * @returns The cached asset object, or `undefined` if the file could not be read. */ getAssetById(id: string, type: ContentTypeItem | ContentTypeMaterial, options?: OpenFileAsJsonAssetOptions): any; /** * This method overwrites the component payload in the file system. * It saves the component payload to the file system and updates the cache. * @param payload The ComponentPayload to overwrite in the file system. * @returns */ storeComponentPayload(payload: ComponentPayload): void; /** * Loads a cached response (e.g. catalog/components) produced by the download pipeline. * * The response is stored inside the project under `//`. If the cached file changes, the entry is refreshed automatically. * * @param catalogId Catalog identifier to scope the response. * @param responseType Type of download response to read. Only `SUPPORTED_DOWNLOADS` are accepted. * @returns The parsed JSON response or `undefined` when missing/invalid. */ getCatalogResponse(catalogId: string, responseType: ResponseType): any; /** * Persists a download response JSON + cache entry that will later be consumed by other tools. * * @param catalogId Catalog identifier matching the download origin. * @param responseType One of the supported response types. * @param response Parsed JSON that will be written to `_.json`. */ storeCatalogResponse(catalogId: string, responseType: ResponseType, response: any): void; /** * Writes an item/material asset to disk and refreshes the cache for the overwritten ID. * * @param id Asset ID (catalog:external) whose file should be overwritten. * @param type Indicates whether the asset belongs in `items` or `materials`. * @param asset Parsed payload to serialize. */ storeAsset(id: string, type: ContentTypeItem | ContentTypeMaterial, asset: any): void; }