npm package: @oronila/nebula-client
Description: Node.js client for Nebula file system API
Author: Nebula Team
Latest version: 1.0.0

# Nebula Node.js Client

A Node.js client library for interacting with the Nebula file system API.

## Installation

```bash
npm install nebula-client
```

## Usage

```javascript
const { NebulaClient } = require('nebula-client');

// Initialize the client with your API key
const client = new NebulaClient({ apiKey: 'your_api_key' });

// List files in a cluster
async function listFiles() {
  try {
    const files = await client.listFiles({
      clusterId: 'your_cluster_id',
      folderId: 'ROOT' // optional, defaults to ROOT
    });
    console.log(files);
  } catch (error) {
    console.error('Error listing files:', error);
  }
}

// Upload a file
async function uploadFile() {
  try {
    const result = await client.uploadFile({
      clusterId: 'your_cluster_id',
      filePath: 'path/to/your/file.txt',
      folderId: 'ROOT' // optional
    });
    console.log(result);
  } catch (error) {
    console.error('Error uploading file:', error);
  }
}

// Download a file
async function downloadFile() {
  try {
    await client.downloadFile({
      clusterId: 'your_cluster_id',
      fileId: 'file_id',
      outputPath: 'path/to/save'
    });
    console.log('File downloaded successfully');
  } catch (error) {
    console.error('Error downloading file:', error);
  }
}

// Create a folder
async function createFolder() {
  try {
    const folder = await client.createFolder({
      clusterId: 'your_cluster_id',
      folderName: 'New Folder',
      parentFolderId: 'ROOT' // optional
    });
    console.log(folder);
  } catch (error) {
    console.error('Error creating folder:', error);
  }
}

// Delete files or folders
async function deleteFiles() {
  try {
    await client.deleteFiles({
      clusterId: 'your_cluster_id',
      fileIds: ['file_id_1', 'file_id_2']
    });
    console.log('Files deleted successfully');
  } catch (error) {
    console.error('Error deleting files:', error);
  }
}

// Move files to a different folder
async function moveFiles() {
  try {
    await client.moveFiles({
      clusterId: 'your_cluster_id',
      fileIds: ['file_id_1', 'file_id_2'],
      targetFolderId: 'target_folder_id'
    });
    console.log('Files moved successfully');
  } catch (error) {
    console.error('Error moving files:', error);
  }
}

// Rename a file or folder
async function renameFile() {
  try {
    await client.renameFile({
      clusterId: 'your_cluster_id',
      fileId: 'file_id',
      newName: 'New Name'
    });
    console.log('File renamed successfully');
  } catch (error) {
    console.error('Error renaming file:', error);
  }
}
```

## API Reference

### NebulaClient

The main client class for interacting with the Nebula API.

#### `constructor({ apiKey, baseUrl })`

Initialize a new client instance.

- `apiKey` (string): Your Nebula API key
- `baseUrl` (string, optional): Custom API base URL. Defaults to production API.

#### File Operations

- `listFiles({ clusterId, folderId })`: List files and folders
- `getUploadUrl({ clusterId, fileName, folderId, contentType })`: Get a pre-signed upload URL
- `uploadFile({ clusterId, filePath, folderId, contentType })`: Upload a file
- `getDownloadUrl({ clusterId, fileId })`: Get a pre-signed download URL
- `downloadFile({ clusterId, fileId, outputPath })`: Download a file
- `createFolder({ clusterId, folderName, parentFolderId })`: Create a folder
- `deleteFiles({ clusterId, fileIds })`: Delete files/folders
- `moveFiles({ clusterId, fileIds, targetFolderId })`: Move files to another folder
- `renameFile({ clusterId, fileId, newName })`: Rename a file/folder

## License

MIT