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:
@@ -0,0 +1,30 @@
|
||||
import { PieceAuth, Property } from '@activepieces/pieces-framework';
|
||||
|
||||
export const graphqlCommon = {
|
||||
connectionType: "graphql",
|
||||
auth: PieceAuth.CustomAuth({
|
||||
required: true,
|
||||
props: {
|
||||
proxyBaseUrl: Property.ShortText({
|
||||
displayName: 'AnyHook Server URL',
|
||||
description: 'The URL of your AnyHook server',
|
||||
required: true,
|
||||
defaultValue: 'http://10.0.0.101:3001'
|
||||
}),
|
||||
},
|
||||
}),
|
||||
apiCall: async function (
|
||||
url: string,
|
||||
method: string,
|
||||
data: object | undefined = undefined
|
||||
) {
|
||||
const response = await fetch(url, {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return response.json();
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
import { TriggerStrategy, createTrigger, PieceAuth, Property } from '@activepieces/pieces-framework';
|
||||
import { createGraphQLSubscription, deleteGraphQLSubscription } from './helpers';
|
||||
import { graphqlCommon } from '../common/common';
|
||||
|
||||
export const graphqlSubscriptionTrigger = createTrigger({
|
||||
auth: graphqlCommon.auth,
|
||||
name: 'graphql_subscription_trigger',
|
||||
displayName: 'New GraphQL Subscription Event',
|
||||
description: 'Triggers on a new GraphQL subscription event',
|
||||
type: TriggerStrategy.WEBHOOK,
|
||||
props: {
|
||||
websocketUrl: Property.ShortText({
|
||||
displayName: 'Endpoint URL',
|
||||
description: 'The GraphQL websocket to connect to.',
|
||||
required: true,
|
||||
defaultValue: 'wss://streaming.bitquery.io/graphql?token=xxxx',
|
||||
}),
|
||||
headers: Property.Object({
|
||||
displayName: 'Headers',
|
||||
description: 'Custom headers for the GraphQL connection, such as authentication tokens.',
|
||||
required: false,
|
||||
}),
|
||||
query: Property.LongText({
|
||||
displayName: 'GraphQL Query',
|
||||
description: 'GraphQL subscription query to listen to events',
|
||||
required: true,
|
||||
defaultValue: 'subscription { EVM(network: eth, trigger_on: head) { Blocks { Block { BaseFee BaseFeeInUSD Bloom Coinbase } } } }',
|
||||
}),
|
||||
},
|
||||
async onEnable(context) {
|
||||
const subscriptionInfo = await createGraphQLSubscription(
|
||||
context.propsValue.websocketUrl,
|
||||
context.propsValue.headers,
|
||||
context.propsValue.query,
|
||||
context.webhookUrl,
|
||||
context.auth.props.proxyBaseUrl
|
||||
);
|
||||
|
||||
// Store subscription info
|
||||
await context.store.put('graphql_subscription_trigger', subscriptionInfo.subscriptionId);
|
||||
},
|
||||
async onDisable(context) {
|
||||
const subscriptionId: string = (await context.store.get('graphql_subscription_trigger')) as string;
|
||||
if (subscriptionId) {
|
||||
await deleteGraphQLSubscription(subscriptionId, context.auth.props.proxyBaseUrl);
|
||||
await context.store.delete('graphql_subscription_trigger');
|
||||
}
|
||||
},
|
||||
async run(context) {
|
||||
return [context.payload.body];
|
||||
},
|
||||
async test(context) {
|
||||
return [
|
||||
{
|
||||
event: 'GraphQL event data',
|
||||
details: 'Details of the event',
|
||||
},
|
||||
];
|
||||
},
|
||||
sampleData: {},
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
import { graphqlCommon } from '../common/common';
|
||||
|
||||
export async function createGraphQLSubscription(
|
||||
websocketUrl: string,
|
||||
headers: Record<string, unknown> | undefined,
|
||||
query: string,
|
||||
webhookUrl: string,
|
||||
proxyBaseUrl: string
|
||||
) {
|
||||
const subscriptionApiUrl = `${proxyBaseUrl}/subscribe`;
|
||||
const data = {
|
||||
connection_type: graphqlCommon.connectionType,
|
||||
webhook_url: webhookUrl,
|
||||
args: {
|
||||
endpoint_url: websocketUrl,
|
||||
headers: headers ? JSON.stringify(headers) : undefined,
|
||||
query,
|
||||
},
|
||||
};
|
||||
const response = await graphqlCommon.apiCall(subscriptionApiUrl, 'POST', data);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function deleteGraphQLSubscription(subscriptionId: string, proxyBaseUrl: string) {
|
||||
const deleteApiUrl = `${proxyBaseUrl}/unsubscribe`;
|
||||
const data = {
|
||||
subscription_id: subscriptionId,
|
||||
};
|
||||
const response = await graphqlCommon.apiCall(deleteApiUrl, 'POST', data);
|
||||
return response;
|
||||
}
|
||||
Reference in New Issue
Block a user