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,26 @@
|
||||
import { PieceAuth } from '@activepieces/pieces-framework';
|
||||
import { makeRequest } from './client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { AppConnectionType } from '@activepieces/shared';
|
||||
|
||||
export const pdfmonkeyAuth = PieceAuth.SecretText({
|
||||
displayName: 'API Key',
|
||||
description: `You can obtain your API key by navigating to [Account Settings](https://dashboard.pdfmonkey.io/account).`,
|
||||
required: true,
|
||||
validate: async ({ auth }) => {
|
||||
try {
|
||||
await makeRequest({
|
||||
type: AppConnectionType.SECRET_TEXT,
|
||||
secret_text: auth,
|
||||
}, HttpMethod.GET, '/documents', {});
|
||||
return {
|
||||
valid: true,
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
valid: false,
|
||||
error: 'Invalid API Key.',
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { HttpMethod, QueryParams, httpClient } from '@activepieces/pieces-common';
|
||||
import { pdfmonkeyAuth } from './auth';
|
||||
import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
|
||||
|
||||
|
||||
export const BASE_URL = `https://api.pdfmonkey.io/api/v1`;
|
||||
|
||||
export async function makeRequest<T>(
|
||||
api_key: AppConnectionValueForAuthProperty<typeof pdfmonkeyAuth>,
|
||||
method: HttpMethod,
|
||||
path: string,
|
||||
query?:QueryParams,
|
||||
body?: unknown,
|
||||
) {
|
||||
try {
|
||||
|
||||
const response = await httpClient.sendRequest<T>({
|
||||
method,
|
||||
url: `${BASE_URL}${path}`,
|
||||
headers: {
|
||||
'Authorization': `Bearer ${api_key.secret_text}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body,
|
||||
queryParams:query
|
||||
});
|
||||
return response.body;
|
||||
|
||||
} catch (error: any) {
|
||||
throw new Error(`Unexpected error: ${error.message || String(error)}`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import { DropdownOption, Property } from '@activepieces/pieces-framework';
|
||||
import { makeRequest } from './client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import { pdfmonkeyAuth } from './auth';
|
||||
|
||||
export const templateIdDropdown = Property.Dropdown({
|
||||
displayName: 'Template ID',
|
||||
auth: pdfmonkeyAuth,
|
||||
required: true,
|
||||
refreshers: [],
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
options: [],
|
||||
placeholder: 'Please connect your account first.',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
let page = 1;
|
||||
let hasMore = true;
|
||||
|
||||
const options: DropdownOption<string>[] = [];
|
||||
|
||||
do {
|
||||
const response = await makeRequest<{
|
||||
document_template_cards: Array<{ id: string; identifier: string }>;
|
||||
meta: { total_pages: number; current_page: number };
|
||||
}>(auth, HttpMethod.GET, '/document_template_cards',{ page: page.toString() });
|
||||
|
||||
const items = response.document_template_cards ?? [];
|
||||
|
||||
for (const template of items) {
|
||||
options.push({ label: template.identifier, value: template.id });
|
||||
}
|
||||
|
||||
page++;
|
||||
hasMore = response.meta.current_page < response.meta.total_pages;
|
||||
} while (hasMore);
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
disabled: true,
|
||||
options: [],
|
||||
placeholder: 'Error loading document templates.',
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const documentIdDropdown = Property.Dropdown({
|
||||
displayName: 'Document ID',
|
||||
required: true,
|
||||
refreshers: [],
|
||||
auth: pdfmonkeyAuth,
|
||||
options: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
disabled: true,
|
||||
options: [],
|
||||
placeholder: 'Please connect your account first.',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
let page = 1;
|
||||
let hasMore = true;
|
||||
|
||||
const options: DropdownOption<string>[] = [];
|
||||
|
||||
do {
|
||||
const response = await makeRequest<{
|
||||
document_cards: Array<{ id: string; filename: string }>;
|
||||
meta: { total_pages: number; current_page: number };
|
||||
}>(auth, HttpMethod.GET, '/document_cards', { page: page.toString() });
|
||||
|
||||
const items = response.document_cards ?? [];
|
||||
|
||||
for (const doc of items) {
|
||||
options.push({ label: doc.filename, value: doc.id });
|
||||
}
|
||||
page++;
|
||||
hasMore = response.meta.current_page < response.meta.total_pages;
|
||||
} while (hasMore);
|
||||
|
||||
return {
|
||||
disabled: false,
|
||||
options,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
disabled: true,
|
||||
options: [],
|
||||
placeholder: 'Error loading documents.',
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user