@pixelstackai/integration
v0.1.0
Published
Toolkit to create Pixelstack integrations
Readme
@pixelstackai/integration
Types and helpers for building Pixelstack integrations: the manifest, the events Pixelstack sends to your handler and the responses it expects.
Install
npm install @pixelstackai/integrationUsage
The manifest
createManifest type-checks your manifest where you write it:
import { createManifest } from '@pixelstackai/integration';
export const manifest = createManifest({
name: 'My Integration',
description: 'What it does',
iconUrl: 'https://example.com/icon.svg',
handlerUrl: 'https://example.com/pixelstack',
supportedEvents: ['installed', 'nodeCalled'],
settings: [],
nodeTypes: [],
});The handler
Pixelstack sends POST requests to your integration's handler. Type the request body with IntegrationEventData:
import { Hono } from 'hono';
import type { IntegrationEventData, IntegrationImageLoaderResponse } from '@pixelstackai/integration';
const app = new Hono();
app.post('/', async (c) => {
const body = await c.req.json<IntegrationEventData>();
if (body.eventType === 'loadImages') {
const response: IntegrationImageLoaderResponse = { images: [] };
return c.json(response);
}
if (body.eventType === 'nodeCalled') {
// body.eventData.nodeTypeId, inputValues and controlValues
}
return c.json({ success: true });
});
export default app;Other types include IntegrationManifest, IntegrationSetting, IntegrationNodeType and IntegrationOutputValue.
Documentation
See Build an integration.
License
MIT
