Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,29 @@
import { createPiece, PieceAuth } from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/shared';
import { createJob } from './lib/actions/create-job';
import { workflowEvent } from './lib/triggers/workflow-event';
export const hystructAuth = PieceAuth.SecretText({
displayName: 'API Key',
description: `
To get your API key:
1. Log in to your Hystruct dashboard
2. Click on your profile picture (top right)
3. Click **Settings**
4. Click **API Keys**
5. Copy and paste your API key here
`,
required: true,
});
export const hystruct = createPiece({
displayName: 'Hystruct',
description: 'AI-powered document structuring and data extraction',
auth: hystructAuth,
minimumSupportedRelease: '0.36.1',
logoUrl: 'https://cdn.activepieces.com/pieces/hystruct.png',
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
authors: ['onyedikachi-david'],
actions: [createJob],
triggers: [workflowEvent],
});

View File

@@ -0,0 +1,29 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { hystructAuth } from '../../index';
import { hystructApiCall } from '../common';
export const createJob = createAction({
auth: hystructAuth,
name: 'create_job',
displayName: 'Create Job',
description: 'Create and queue a new job to run for a workflow',
props: {
workflowId: Property.ShortText({
displayName: 'Workflow ID',
description: 'The ID of the workflow to run',
required: true,
}),
},
async run(context) {
const { workflowId } = context.propsValue;
const response = await hystructApiCall<{ message: string }>({
apiKey: context.auth.secret_text,
method: HttpMethod.POST,
endpoint: `/v1/workflows/${workflowId}/queue`,
});
return response;
},
});

View File

@@ -0,0 +1,42 @@
import { HttpMethod, httpClient, HttpMessageBody, QueryParams } from '@activepieces/pieces-common';
export const HYSTRUCT_BASE_URL = 'https://api.hystruct.com';
export type HystructApiCallParams = {
apiKey: string;
method: HttpMethod;
endpoint: string;
query?: Record<string, string | number | string[] | undefined>;
body?: unknown;
};
export async function hystructApiCall<T extends HttpMessageBody>({
apiKey,
method,
endpoint,
query,
body,
}: HystructApiCallParams): Promise<T> {
const qs: QueryParams = {};
if (query) {
for (const [key, value] of Object.entries(query)) {
if (value !== null && value !== undefined) {
qs[key] = String(value);
}
}
}
const response = await httpClient.sendRequest<T>({
method,
url: `${HYSTRUCT_BASE_URL}${endpoint}`,
headers: {
'x-api-key': apiKey,
'Content-Type': 'application/json',
},
queryParams: qs,
body,
});
return response.body;
}

View File

@@ -0,0 +1 @@
export * from './client';

View File

@@ -0,0 +1,59 @@
import { createTrigger, Property, TriggerStrategy } from '@activepieces/pieces-framework';
import { hystructAuth } from '../../index';
export const workflowEvent = createTrigger({
auth: hystructAuth,
name: 'workflow_event',
displayName: 'Workflow Event',
description: 'Triggers when a workflow event occurs (e.g., job completed, data updated)',
type: TriggerStrategy.WEBHOOK,
props: {
markdown: Property.MarkDown({
value: `## Webhook Setup
To receive workflow events, set up a webhook in your Hystruct dashboard:
1. Log in to Hystruct and go to **Integrations**
2. Click **Webhooks** → **Create webhook**
3. Paste this URL as the Webhook URL:
\`\`\`text
{{webhookUrl}}
\`\`\`
4. Select the events you want to subscribe to
5. Optionally enter a Workflow ID to filter events
6. Click **Save**
`,
}),
},
async onEnable() {
// User configures webhook manually in Hystruct dashboard
},
async onDisable() {
// User removes webhook manually in Hystruct dashboard
},
async run(context) {
return [context.payload.body];
},
async test() {
return [
{
workflowId: 'wf_abc123',
event: 'job.completed',
data: {
jobId: 'job_xyz789',
status: 'completed',
completedAt: new Date().toISOString(),
},
},
];
},
sampleData: {
workflowId: 'wf_abc123',
event: 'job.completed',
data: {
jobId: 'job_xyz789',
status: 'completed',
completedAt: '2024-01-15T10:30:00Z',
},
},
});