inkflow-sdk
v2.0.0
Published
Official JavaScript/TypeScript SDK for Inkflow API
Maintainers
Readme
Inkflow SDK
Official JavaScript/TypeScript SDK for the Inkflow API.
Installation
npm install inkflow-sdkQuick Start
import InkflowClient from 'inkflow-sdk';
const client = new InkflowClient({
apiKey: 'your-api-key-here'
});
// Test connection
const isConnected = await client.ping();
console.log('Connected:', isConnected);Authentication
// Authenticate a user from your external system
const authResult = await client.auth.authenticate({
external_user_id: 'user123',
email: '[email protected]',
display_name: 'John Doe',
metadata: { role: 'admin' }
});
if (authResult.success) {
console.log('User authenticated:', authResult.user);
}
// Get user information
const user = await client.auth.getUser('user123');
console.log('User info:', user);
// Update user
const updatedUser = await client.auth.updateUser('user123', {
display_name: 'John Smith',
metadata: { role: 'editor' }
});Content Management
// Create content
const content = await client.content.create({
title: 'My Article',
content: {
body: 'Article content here...',
excerpt: 'Short description'
},
content_type: 'article',
is_published: true
}, 'user123'); // optional external_user_id
// Get content
const article = await client.content.get(content.id);
// List content
const contentList = await client.content.list({
page: 1,
limit: 10,
content_type: 'article',
is_published: true
});
// Update content
const updated = await client.content.update(content.id, {
title: 'Updated Title',
is_published: false
});
// Delete content
const deleted = await client.content.delete(content.id);TypeScript Support
The SDK is written in TypeScript and includes full type definitions:
import InkflowClient, { ContentItem, ExternalUser } from 'inkflow-sdk';
const client = new InkflowClient({ apiKey: 'your-key' });
const user: ExternalUser | null = await client.auth.getUser('user123');
const content: ContentItem = await client.content.create({
title: 'Typed Content',
content: { body: 'Content here' },
content_type: 'article'
});Error Handling
try {
const content = await client.content.create({
title: 'Test Article',
content: { body: 'Content' },
content_type: 'article'
});
} catch (error) {
console.error('Failed to create content:', error.message);
}Configuration
const client = new InkflowClient({
apiKey: 'your-api-key',
baseUrl: 'https://your-custom-domain.com' // optional, defaults to Supabase URL
});API Reference
Authentication Methods
auth.authenticate(userData)- Authenticate a userauth.getUser(external_user_id)- Get user informationauth.updateUser(external_user_id, updates)- Update user data
Content Methods
content.create(contentData, external_user_id?)- Create new contentcontent.get(id)- Get content by IDcontent.list(options?)- List content with paginationcontent.update(id, updates, external_user_id?)- Update contentcontent.delete(id, external_user_id?)- Delete content
Utility Methods
ping()- Test API connection
License
MIT
