open-index/open-npm huggingface dataset:
npm package: @sheet2db/sdk
Description: The `Sheet2DBClient` SDK allows developers to interact with their Google Sheets via the Sheet2DB platform using a clean and typed interface. It provides full CRUD support along with helper utilities for managing sheets.
Latest version: 2.0.6

# 📘 Sheet2DBClient SDK

The `Sheet2DBClient` SDK allows developers to interact with their Google Sheets via the Sheet2DB platform using a clean and typed interface. It provides full CRUD support along with helper utilities for managing sheets.

---

## 📦 Installation

```bash
npm install @sheet2db/sdk
```

---

## 🚀 Usage

```ts
import { Sheet2DBClient } from '@sheet2db/sdk';

const client = new Sheet2DBClient('your-api-id');

// Optional authentication
client.useBearerTokenAuthentication('your-token');

// Example: Read rows
const data = await client.Read({ limit: 10 }, 'Sheet1');
```

---

## 🔐 Authentication Methods

```ts
client.useBasicAuthentication(username: string, password: string);
client.useJWTAuthentication(token: string);
client.useBearerTokenAuthentication(token: string);
```

---

## 🧠 Type Definitions

### `ReadOptions`

```ts
{
  limit?: number;
  offset: number;
  sortColumn?: string;
  sortDirection: 'asc' | 'desc';
  sortColumnFormat?: 'date';
  filter?: string;
  format: 'rows' | 'columns' | 'matrix';
  columns?: string[];
  castNumbers?: string[];
}
```

### `InsertOptions`

```ts
{
  data: any[];
}
```

### `UpdateOptions`

```ts
// Update by row
{
  type: 'row';
  row: number;
  data: Record<string, any>;
}

// Update by filter
{
  type: 'filter';
  filter: string;
  data: Record<string, any>;
}
```

### `DeleteOptions`

```ts
// Delete by row
{
  type: 'row';
  row: number;
}

// Delete by filter
{
  type: 'filter';
  filter: string;
}
```

### `AddSheetOptions`

```ts
{
  name: string;
  firstRow?: string[];
  copyColumnsFrom?: string;
}
```

---

## 📚 Methods

### `Read<T>(options: ReadOptions, sheet?: string): Promise<T>`

Reads data from the sheet based on options provided.

---

### `Insert(options: InsertOptions, sheet?: string): Promise<{ inserted: number }>`

Inserts rows of data into the specified sheet.

---

### `Update(options: UpdateOptions, sheet?: string): Promise<{ updated: number }>`

Updates rows based on a filter or row number.

---

### `Delete(options: DeleteOptions, sheet?: string): Promise<{ deleted: number }>`

Deletes rows based on a filter or row number.

---

### `AddSheet(options: AddSheetOptions): Promise<{ ok: true }>`

Adds a new sheet with optional headers or by copying from another sheet.

---

### `DeleteSheet(sheet: string): Promise<{ ok: true }>`

Deletes a sheet by name.

---

## 🧪 Example

```ts
await client.Insert({
  data: [
    { name: 'Alice', age: 28 },
    { name: 'Bob', age: 31 }
  ]
}, 'People');

await client.Update({
  type: 'row',
  row: 2,
  data: { age: 32 }
}, 'People');

await client.Delete({
  type: 'filter',
  filter: 'name:eq:Bob'
}, 'People');
```

---

## 🧾 Notes

* All options are validated using `zod` for runtime type safety.
* `sheet` argument is optional; default sheet will be used if not specified.
* Supports pagination, sorting, and filtering.