UNPKG

@grasplabs/grasp

Version:

TypeScript SDK for browser automation and secure command execution in highly available and scalable cloud browser environments

54 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FileSystemService = void 0; const logger_1 = require("../utils/logger"); class FileSystemService { /** * Gets or creates a default logger instance * @returns Logger instance */ getDefaultLogger() { try { return (0, logger_1.getLogger)().child('TerminalService'); } catch (error) { // If logger is not initialized, create a default one const defaultLogger = new logger_1.Logger({ level: this.sandbox.isDebug ? 'debug' : 'info', console: true, }); return defaultLogger.child('TerminalService'); } } constructor(sandbox, connection) { this.sandbox = sandbox; this.connection = connection; this.logger = this.getDefaultLogger(); } async uploadFile(localPath, remotePath) { const uploadResult = await this.sandbox.uploadFileToSandbox(localPath, remotePath); return uploadResult; } async downloadFile(remotePath, localPath) { const downloadResult = await this.sandbox.copyFileFromSandbox(remotePath, localPath); return downloadResult; } async writeFile(remotePath, content) { const writeResult = await this.sandbox.writeFileToSandbox(remotePath, content); return writeResult; } async readFile(remotePath, options = {}) { const readResult = await this.sandbox.readFileFromSandbox(remotePath, options); return readResult; } /** * @experimental This method is experimental and may change or be removed in future versions. * Use with caution in production environments. */ async syncDownloadsDirectory(localPath, remotePath = localPath) { const syncResult = await this.sandbox.syncDownloadsDirectory(localPath, remotePath); return syncResult; } } exports.FileSystemService = FileSystemService; //# sourceMappingURL=filesystem.service.js.map