npm package: @simplystack-org/sdk
Description: A comprehensive TypeScript SDK for SimplyStack API - manage blog posts, storage, email, and logs
Author: SimplyStack
Latest version: 0.0.8

# SimplyStack SDK

The official TypeScript SDK for SimplyStack - manage your blog posts, storage assets, email communications, and logs with ease.

## 🚀 Installation

```bash
npm install @simplystack-org/sdk
```

## ⚡ Quick Start

Simply provide your project secret key:

```typescript
import { SimplyStackSDK } from "@simplystack-org/sdk";

// Initialize with your project secret
const sdk = new SimplyStackSDK("your-project-secret-key");

// Start using immediately
const { data: posts, error } = await sdk.getBlogPosts();
```

## 📝 Blog Posts

```typescript
// Get all blog posts
const { data: posts, error } = await sdk.getBlogPosts();

// Get a specific post
const { data: post, error } = await sdk.getBlogPost("post-id");

// Create a new post
const { data: post, error } = await sdk.createBlogPost({
  title: "My New Post",
  content: "<h1>Hello World</h1>",
  meta_title: "SEO Title",
  meta_description: "SEO description",
});

// Update a post
const { data: post, error } = await sdk.updateBlogPost("post-id", {
  title: "Updated Title",
});
```

## 🖼️ Storage & File Management

```typescript
// Upload a file
const { data: asset, error } = await sdk.uploadFile(file, "My Image");

// Get storage assets
const { data: assets, error } = await sdk.getStorageAssets();

// Get responsive image URLs
const { data: thumbnail } = await sdk.getThumbnailUrl("asset-id", 200);
const { data: responsive } = await sdk.getResponsiveImageUrl("asset-id", 800);
```

## 📧 Email & Lead Management

```typescript
// Setup email configuration
const { data: config, error } = await sdk.setupEmailConfiguration({
  fromName: "Your Company",
});

// Send an email
const { data: email, error } = await sdk.sendEmail({
  to: "user@example.com",
  subject: "Welcome!",
  html: "<h1>Welcome to our service!</h1>",
});

// Create a lead
const { data: lead, error } = await sdk.createLead({
  email: "lead@example.com",
  name: "John Doe",
  source: "website",
});

// Send welcome email
const { data: email, error } = await sdk.sendWelcomeEmail("user@example.com", {
  name: "John Doe",
});
```

## 📊 Logging

```typescript
// Create a log entry
const { data: log, error } = await sdk.createLog({
  level: "info",
  message: "User logged in",
  context: "auth",
});

// Get logs with filters
const { data: logs, error } = await sdk.getLogs({
  level: "error",
  limit: 50,
});
```

## 🔒 Error Handling

All methods return a consistent response format:

```typescript
const { data, error } = await sdk.someMethod();

if (error) {
  console.error("Operation failed:", error);
  return;
}

// Use data safely
console.log("Success:", data);
```

## 🎯 TypeScript Support

Full TypeScript support with auto-completion:

```typescript
import { SimplyStackSDK, BlogPost, StorageAsset } from "@simplystack-org/sdk";

const sdk = new SimplyStackSDK("your-key");

// Full type safety
const { data: post }: { data?: BlogPost; error?: string } =
  await sdk.getBlogPost("post-id");
```

## 📚 Advanced Examples

### Complete Blog Workflow

```typescript
const sdk = new SimplyStackSDK("your-project-secret");

// Create a post
const { data: post, error } = await sdk.createBlogPost({
  title: "Getting Started Guide",
  content: "<h1>Welcome!</h1><p>This is a comprehensive guide...</p>",
  meta_title: "Complete Getting Started Guide",
  meta_description: "Everything you need to know to get started",
});

if (error) {
  console.error("Failed to create post:", error);
} else {
  console.log("Post created successfully:", post.title);
}
```

### File Upload with Processing

```typescript
// Upload and get different image sizes
const file = document.querySelector("input").files[0];

const { data: asset, error } = await sdk.uploadFile(file, "Profile Picture");

if (!error) {
  // Get different sizes
  const { data: thumb } = await sdk.getThumbnailUrl(asset.id, 150);
  const { data: large } = await sdk.getResponsiveImageUrl(asset.id, 1200);

  console.log("Thumbnail:", thumb.url);
  console.log("Large image:", large.url);
}
```

## 🆘 Support

- **Documentation**: [GitHub Repository](https://github.com/simplystack-org/simplystack-sdk)
- **Issues**: [Report a Bug](https://github.com/simplystack-org/simplystack-sdk/issues)
- **Email**: contact@simplystack.com

## 📄 License

MIT License - see [GitHub](https://github.com/simplystack-org/simplystack-sdk) for details.