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,27 @@
|
||||
import { createPiece } from '@activepieces/pieces-framework';
|
||||
import { signrequestAuth } from './lib/common/auth';
|
||||
import { PieceCategory } from '@activepieces/shared';
|
||||
import { sendSignrequest } from './lib/actions/send-signrequest';
|
||||
import { createCustomApiCallAction } from '@activepieces/pieces-common';
|
||||
|
||||
export const signrequest = createPiece({
|
||||
displayName: 'Signrequest',
|
||||
auth: signrequestAuth,
|
||||
minimumSupportedRelease: '0.36.1',
|
||||
logoUrl: 'https://cdn.activepieces.com/pieces/signrequest.png',
|
||||
categories: [PieceCategory.SALES_AND_CRM],
|
||||
authors: ['sanket-a11y'],
|
||||
actions: [
|
||||
sendSignrequest,
|
||||
createCustomApiCallAction({
|
||||
auth: signrequestAuth,
|
||||
baseUrl: () => 'https://signrequest.com/api/v1',
|
||||
authMapping: async (auth) => {
|
||||
return {
|
||||
Authorization: auth.secret_text,
|
||||
};
|
||||
},
|
||||
}),
|
||||
],
|
||||
triggers: [],
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { signrequestAuth } from '../common/auth';
|
||||
|
||||
export const sendSignrequest = createAction({
|
||||
auth: signrequestAuth,
|
||||
name: 'send_signrequest',
|
||||
displayName: 'Send signrequest',
|
||||
description: 'Create a SignRequest via the Signrequest API',
|
||||
props: {
|
||||
title: Property.ShortText({
|
||||
displayName: 'Title',
|
||||
required: true,
|
||||
}),
|
||||
subject: Property.ShortText({
|
||||
displayName: 'Subject',
|
||||
required: false,
|
||||
}),
|
||||
message: Property.LongText({
|
||||
displayName: 'Message',
|
||||
required: false,
|
||||
}),
|
||||
signers: Property.Json({
|
||||
displayName: 'Signers (JSON array)',
|
||||
description:
|
||||
'JSON array of signer objects. Example: [{"email":"john@example.com","name":"John Doe","role":"signer"}]',
|
||||
required: true,
|
||||
}),
|
||||
files: Property.Json({
|
||||
displayName: 'Files (JSON array)',
|
||||
description:
|
||||
'Optional JSON array describing files to attach. Use the shape expected by the Signrequest API (e.g. [{"url":"https://..."}])',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run({ propsValue, auth }) {
|
||||
const { title, subject, message, signers, files } = propsValue;
|
||||
|
||||
const body: any = {
|
||||
title,
|
||||
};
|
||||
|
||||
if (subject) body.subject = subject;
|
||||
if (message) body.message = message;
|
||||
|
||||
if (signers) {
|
||||
body.signers = signers;
|
||||
}
|
||||
|
||||
if (files) {
|
||||
body.files = files;
|
||||
}
|
||||
|
||||
const response = await makeRequest(
|
||||
auth.secret_text,
|
||||
HttpMethod.POST,
|
||||
'/signrequests/',
|
||||
body
|
||||
);
|
||||
|
||||
return response;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { PieceAuth } from '@activepieces/pieces-framework';
|
||||
|
||||
export const signrequestAuth = PieceAuth.SecretText({
|
||||
displayName: 'API Key',
|
||||
description: 'Signrequest API Key',
|
||||
required: true,
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
|
||||
|
||||
export const BASE_URL = `https://signrequest.com/api/v1`;
|
||||
|
||||
export async function makeRequest(
|
||||
api_key: string,
|
||||
method: HttpMethod,
|
||||
path: string,
|
||||
body?: unknown
|
||||
) {
|
||||
try {
|
||||
const response = await httpClient.sendRequest({
|
||||
method,
|
||||
url: `${BASE_URL}${path}`,
|
||||
headers: {
|
||||
Authorization: `${api_key}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body,
|
||||
});
|
||||
|
||||
return response.body;
|
||||
} catch (error: any) {
|
||||
throw new Error(`Unexpected error: ${error.message || String(error)}`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
|
||||
import { signrequestAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const signrequestDeclined = createTrigger({
|
||||
auth: signrequestAuth,
|
||||
name: 'signrequestDeclined',
|
||||
displayName: 'signrequest declined',
|
||||
description: 'Fires when a SignRequest is declined',
|
||||
props: {},
|
||||
sampleData: {},
|
||||
type: TriggerStrategy.WEBHOOK,
|
||||
async onEnable(context) {
|
||||
const apiKey = context.auth.secret_text;
|
||||
|
||||
const body = {
|
||||
url: context.webhookUrl,
|
||||
events: ['declined'],
|
||||
};
|
||||
|
||||
const response = await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.POST,
|
||||
'/webhooks/',
|
||||
body
|
||||
);
|
||||
await context.store.put('signrequest_declined_webhook', response.uuid);
|
||||
},
|
||||
async onDisable(context) {
|
||||
const apiKey = context.auth.secret_text;
|
||||
const webhookId = await context.store.get<any>(
|
||||
'signrequest_declined_webhook'
|
||||
);
|
||||
|
||||
if (!webhookId) {
|
||||
console.debug('No Signrequest webhook found in store to delete');
|
||||
return;
|
||||
}
|
||||
|
||||
await makeRequest(apiKey, HttpMethod.DELETE, `/webhooks/${webhookId}/`);
|
||||
await context.store.delete('signrequest_declined_webhook');
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.payload.body as any;
|
||||
if (body.event_type !== 'declined') {
|
||||
return [];
|
||||
}
|
||||
return [context.payload.body];
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
|
||||
import { signrequestAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
export const signrequestReceived = createTrigger({
|
||||
auth: signrequestAuth,
|
||||
name: 'signrequestReceived',
|
||||
displayName: 'signrequest received',
|
||||
description: 'Triggers when a SignRequest is received',
|
||||
props: {},
|
||||
sampleData: {},
|
||||
type: TriggerStrategy.WEBHOOK,
|
||||
async onEnable(context) {
|
||||
const apiKey = context.auth.secret_text;
|
||||
|
||||
const body = {
|
||||
url: context.webhookUrl,
|
||||
events: ['signrequest_received'],
|
||||
};
|
||||
|
||||
const response = await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.POST,
|
||||
'/webhooks/',
|
||||
body
|
||||
);
|
||||
await context.store.put('signrequest_received_webhook', response.uuid);
|
||||
},
|
||||
async onDisable(context) {
|
||||
const apiKey = context.auth.secret_text;
|
||||
const webhookId = await context.store.get<any>(
|
||||
'signrequest_received_webhook'
|
||||
);
|
||||
|
||||
if (!webhookId) {
|
||||
console.debug('No Signrequest webhook found in store to delete');
|
||||
return;
|
||||
}
|
||||
|
||||
await makeRequest(apiKey, HttpMethod.DELETE, `/webhooks/${webhookId}/`);
|
||||
await context.store.delete('signrequest_received_webhook');
|
||||
},
|
||||
async run(context) {
|
||||
const body = context.payload.body as any;
|
||||
if (body.event_type !== 'signrequest_received') {
|
||||
return [];
|
||||
}
|
||||
return [context.payload.body];
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
|
||||
import { signrequestAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
export const signrequestSigned = createTrigger({
|
||||
auth: signrequestAuth,
|
||||
name: 'signrequestSigned',
|
||||
displayName: 'signrequest signed',
|
||||
description: 'Triggers when a SignRequest signer is signed',
|
||||
props: {},
|
||||
sampleData: {},
|
||||
type: TriggerStrategy.WEBHOOK,
|
||||
async onEnable(context) {
|
||||
const apiKey = context.auth.secret_text;
|
||||
const body = {
|
||||
url: context.webhookUrl,
|
||||
events: ['signer_signed'],
|
||||
};
|
||||
const response = await makeRequest(
|
||||
apiKey,
|
||||
HttpMethod.POST,
|
||||
'/webhooks/',
|
||||
body
|
||||
);
|
||||
await context.store.put('signrequest_signed_webhook', response.uuid);
|
||||
},
|
||||
async onDisable(context) {
|
||||
const apiKey = context.auth.secret_text;
|
||||
const webhookId = await context.store.get<any>(
|
||||
'signrequest_signed_webhook'
|
||||
);
|
||||
|
||||
if (!webhookId) {
|
||||
console.debug('No Signrequest webhook found in store to delete');
|
||||
return;
|
||||
}
|
||||
|
||||
await makeRequest(apiKey, HttpMethod.DELETE, `/webhooks/${webhookId}/`);
|
||||
await context.store.delete('signrequest_signed_webhook');
|
||||
},
|
||||
async run(context) {
|
||||
return [context.payload.body];
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user