UNPKG

@sap-ux/project-access

Version:

Library to access SAP Fiori tools projects

142 lines 6.38 kB
import type { Logger } from '@sap-ux/logger'; import type { Editor } from 'mem-fs-editor'; import type { CapCustomPaths, CapProjectType, CdsEnvironment, csn, Package, ServiceDefinitions, ServiceInfo, CdsVersionInfo } from '../types'; /** * Returns true if the project is a CAP Node.js project. * * @param packageJson - the parsed package.json object * @returns - true if the project is a CAP Node.js project */ export declare function isCapNodeJsProject(packageJson: Package): boolean; /** * Returns true if the project is a CAP Java project. * * @param projectRoot - the root path of the project * @param [capCustomPaths] - optional, relative CAP paths like app, db, srv * @param memFs - optional mem-fs-editor instance * @returns - true if the project is a CAP project */ export declare function isCapJavaProject(projectRoot: string, capCustomPaths?: CapCustomPaths, memFs?: Editor): Promise<boolean>; /** * Returns the CAP project type, undefined if it is not a CAP project. * * @param projectRoot - root of the project, where the package.json resides. * @param memFs - optional mem-fs-editor instance * @returns - CAPJava for Java based CAP projects; CAPNodejs for node.js based CAP projects; undefined if it is no CAP project */ export declare function getCapProjectType(projectRoot: string, memFs?: Editor): Promise<CapProjectType | undefined>; /** * Returns true if the project is either a CAP Node.js or a CAP Java project. * * @param projectRoot - the root path of the project * @returns - true if the project is a CAP project */ export declare function isCapProject(projectRoot: string): Promise<boolean>; /** * Get CAP CDS project custom paths for project root. * * @param capProjectPath - project root of cap project * @returns - paths to app, db, and srv for CAP project */ export declare function getCapCustomPaths(capProjectPath: string): Promise<CapCustomPaths>; /** * Return the CAP model and all services. The cds.root will be set to the provided project root path. * * @param projectRoot - CAP project root where package.json resides or object specifying project root and optional logger to log additional info * @returns {Promise<{ model: csn; services: ServiceInfo[]; cdsVersionInfo: CdsVersionInfo }>} - CAP Model and Services */ export declare function getCapModelAndServices(projectRoot: string | { projectRoot: string; logger?: Logger; pathSelection?: Set<'app' | 'srv' | 'db'>; }): Promise<{ model: csn; services: ServiceInfo[]; cdsVersionInfo: CdsVersionInfo; }>; /** * Returns a list of cds file paths (layers). By default return list of all, but you can also restrict it to one envRoot. * * @param projectRoot - root of the project, where the package.json is * @param [ignoreErrors] - optionally, default is false; if set to true the thrown error will be checked for CDS file paths in model and returned * @param [envRoot] - optionally, the root folder or CDS file to get the layer files * @returns - array of strings containing cds file paths */ export declare function getCdsFiles(projectRoot: string, ignoreErrors?: boolean, envRoot?: string | string[]): Promise<string[]>; /** * Returns a list of filepaths to CDS files in root folders. Same what is done if you execute cds.resolve('*') on command line in a project. * * @param projectRoot - root of the project, where the package.json is * @param [clearCache] - optionally, clear the cache, default false * @returns - array of root paths */ export declare function getCdsRoots(projectRoot: string, clearCache?: boolean): Promise<string[]>; /** * Return a list of services in a CAP project. * * @param projectRoot - root of the CAP project, where the package.json is * @param ignoreErrors - in case loading the cds model throws an error, try to use the model from the exception object * @returns - array of service definitions */ export declare function getCdsServices(projectRoot: string, ignoreErrors?: boolean): Promise<ServiceDefinitions[]>; /** * Return the EDMX string of a CAP service. * * @param root - CAP project root where package.json resides * @param uri - service path, e.g 'incident/' * @param version - optional OData version v2 or v4 * @returns - string containing the edmx */ export declare function readCapServiceMetadataEdmx(root: string, uri: string, version?: 'v2' | 'v4'): Promise<string>; /** * Get CAP CDS project environment config for project root. * * @param capProjectPath - project root of a CAP project * @returns - environment config for a CAP project */ export declare function getCapEnvironment(capProjectPath: string): Promise<CdsEnvironment>; /** * Method to clear CAP CDS module cache for passed project path. * * @param projectRoot root of a CAP project. * @returns True if cache cleared successfully. */ export declare function clearCdsModuleCache(projectRoot: string): Promise<boolean>; /** * Get absolute path to a resource. * * @param projectRoot - project root of a CAP project * @param relativeUri - relative resource path. * @returns {string} - absolute path. */ export declare const toAbsoluteUri: (projectRoot: string, relativeUri: string) => string; /** * Converts to referenced uri to be used in using statements. * * @param projectRoot - project root of a CAP project * @param relativeUriFrom - relative uri of from directory * @param relativeUriTo - relative uri of to directory * @returns {Promise<string>} - reference uri */ export declare const toReferenceUri: (projectRoot: string, relativeUriFrom: string, relativeUriTo: string) => Promise<string>; /** * Clear cache of request to load global cds module. */ export declare function clearGlobalCdsModulePromiseCache(): void; /** * Method resolves cap service name for passed project root and service uri. * * @param projectRoot - project root * @param datasourceUri - service uri * @returns - found cap service name */ export declare function getCapServiceName(projectRoot: string, datasourceUri: string): Promise<string>; /** * Delete application from CAP project. * * @param appPath - path to the application in a CAP project * @param [memFs] - optional mem-fs-editor instance * @param [logger] - function to log messages (optional) */ export declare function deleteCapApp(appPath: string, memFs?: Editor, logger?: Logger): Promise<void>; //# sourceMappingURL=cap.d.ts.map