import { ContentTypeComponent, ContentTypeItem, ContentTypeMaterial } from './contenttypes'; /** * Safely opens a file as JSON, with an option to escape newlines in the content. * @param filepath the path to the file to be opened and parsed as JSON * @returns undefined if the file doesn't exist or is not a valid JSON, otherwise returns the parsed JSON object. */ export declare function getJsonFromFile(filepath: string): any | undefined; /** * Opens a file as JSON which has newlines in its values. Useful for component definitions. * @param filepath the path to the file to be opened and parsed as JSON * @returns undefined if the file doesn't exist or is not a valid JSON, otherwise returns the parsed JSON object. */ export declare function getEscapedJsonFromFile(filepath: string): any | undefined; /** * Reads the content of a file as text. * @param filepath the path to the file to be read * @returns the content of the file as a string, or undefined if the file doesn't exist or cannot be read. */ export declare function getFileContentAsString(filepath: string): string | undefined; /** * mkDirSync a writeFileSync wrapper. * If data is string, it is written as is. * If data is an object, it is stringified with JSON.stringify and written to the file. * @param filepath * @param data * @param indent */ export declare function saveObjectAsFile(filepath: string, data: any, indent?: number): void; export declare function saveTextAsFile(filepath: string, data: string): void; export declare function saveCsvAsFile(filepath: string, header: [], data: []): void; /** * Wrapper of https.get that returns a promise with the JSON response. * @param url * @returns */ export declare function httpsGetJson(url: any): Promise; /** * Wrapper of https.get that returns a promise with the file downloaded to the specified filepath. */ export declare function httpsGetFile(url: string, filepath: string): Promise; export type OpenFileAsJsonAssetOptions = { fillIds?: boolean; overwriteIds?: boolean; useJsonConfiguration?: boolean; }; /** * Open a JSON file that is a item or material asset definition. The file is updated with the id passed in. * The id is used to fill the externalIdentifier, id and catalog fields of the asset, so that it can be freely copied and its path is defining the id. * @param rootPath project root path where the content folder is located * @param intendedId the id of the asset to be opened * @param assetType materials or items; other types are not supported * @param options fillIds: if true, the ids of the asset will be filled with the id passed in; overwriteIds: if true, the ids of the asset will be overwritten with the id passed in the intendedId; useJsonConfiguration: if true, the jsonConfiguration field will be used instead of configuration. * @returns */ export declare function openFileAsJsonAsset(filePath: string, intendedId: string | undefined, assetType: ContentTypeMaterial | ContentTypeItem, options?: OpenFileAsJsonAssetOptions): any; /** * @param root project root folder. Folder called CTSettings.contentFolderName is expected in this folder. * @param typeFolder components, items, materials ... etc. * @param id full ID in the catalogueId:externalId format * @param useContentFolder if true, the content folder is expected behind the root path * @returns expected path to the file. doesn't check if the file exists */ export declare function getPathFromId(root: string, typeFolder: ContentTypeItem | ContentTypeMaterial | ContentTypeComponent, id: string, useContentFolder?: boolean): string; export declare function getFileTimestamp(filepath: string): number | undefined;