@flowtile/adapters
v0.1.0
Published
Storage adapters for FlowTile ticket workflow system
Maintainers
Readme
@flowtile/adapters
Storage adapters for FlowTile ticket workflow system.
Installation
npm install @flowtile/adapters @flowtile/coreAvailable Adapters
SupabaseAdapter
For Supabase/PostgreSQL databases. Uses JSONB columns for flexible storage.
import { SupabaseAdapter } from '@flowtile/adapters/supabase';
import { TicketEngine, presets } from '@flowtile/core';
const adapter = new SupabaseAdapter({
supabaseUrl: process.env.SUPABASE_URL!,
supabaseKey: process.env.SUPABASE_ANON_KEY!,
tableName: 'tickets' // optional, defaults to 'tickets'
});
const engine = new TicketEngine({
workflow: presets.helpDesk(),
storage: adapter
});Database Setup
Run the included SQL schema to set up your Supabase database:
-- See packages/adapters/src/supabase/schema.sqlOr apply it via Supabase CLI:
supabase db pushRestAdapter
Generic adapter for HTTP/REST APIs. Works with any backend implementing the FlowTile API contract.
import { RestAdapter } from '@flowtile/adapters/rest';
import { TicketEngine, presets } from '@flowtile/core';
const adapter = new RestAdapter({
baseUrl: 'https://api.example.com/v1',
authToken: 'Bearer your-token',
headers: {
'X-Custom-Header': 'value'
},
endpoints: { // optional, these are the defaults
getAll: '/tickets',
getById: '/tickets/:id',
create: '/tickets',
update: '/tickets/:id',
delete: '/tickets/:id',
query: '/tickets/query'
}
});
const engine = new TicketEngine({
workflow: presets.bugTracker(),
storage: adapter
});API Contract
Your REST API should implement these endpoints:
GET /tickets- Get all ticketsGET /tickets/:id- Get ticket by IDPOST /tickets- Create a ticketPUT /tickets/:id- Update a ticketDELETE /tickets/:id- Delete a ticketPOST /tickets/query- Query tickets with filters
Custom Adapters
You can create your own adapter by implementing the StorageAdapter interface:
import type { StorageAdapter, Ticket, StageKey, TicketFilters } from '@flowtile/core';
export class MyCustomAdapter<TKey extends StageKey = StageKey>
implements StorageAdapter<TKey> {
async getAll(): Promise<Ticket<TKey>[]> {
// Your implementation
}
async getById(id: string): Promise<Ticket<TKey> | null> {
// Your implementation
}
async create(ticket: Ticket<TKey>): Promise<Ticket<TKey>> {
// Your implementation
}
async update(ticket: Ticket<TKey>): Promise<Ticket<TKey>> {
// Your implementation
}
async delete(id: string): Promise<boolean> {
// Your implementation
}
async query(filters: TicketFilters<TKey>): Promise<Ticket<TKey>[]> {
// Your implementation
}
}License
MIT
