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,20 @@
|
||||
import { createPiece } from "@activepieces/pieces-framework";
|
||||
import { PieceCategory } from "@activepieces/shared";
|
||||
import { parserExpertAuth } from "./lib/common/auth";
|
||||
import { uploadDocument } from "./lib/actions/upload-document";
|
||||
import { getExtractedData } from "./lib/actions/get-extracted-data";
|
||||
|
||||
export const parserExpert = createPiece({
|
||||
displayName: "Parser Expert",
|
||||
auth: parserExpertAuth,
|
||||
minimumSupportedRelease: '0.36.1',
|
||||
logoUrl: "https://cdn.activepieces.com/pieces/parser-expert.png",
|
||||
description: "Parse documents and extract data from PDFs, DOCX files, images, and webpages using Parser Expert's powerful API.",
|
||||
categories: [PieceCategory.CONTENT_AND_FILES],
|
||||
authors: ["onyedikachi-david"],
|
||||
actions: [
|
||||
uploadDocument,
|
||||
getExtractedData,
|
||||
],
|
||||
triggers: [],
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { parserExpertAuth } from '../common/auth';
|
||||
import { parserExpertCommon } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const getExtractedData = createAction({
|
||||
auth: parserExpertAuth,
|
||||
name: 'get_extracted_data',
|
||||
displayName: 'Get Extracted Data',
|
||||
description: 'Retrieve the extracted data using the parser ID and bucket ID. The parser ID is returned when you upload a document.',
|
||||
props: {
|
||||
parser_id: Property.ShortText({
|
||||
displayName: 'Parser ID',
|
||||
description: 'The ID of the parser. This is returned when content is uploaded.',
|
||||
required: true,
|
||||
}),
|
||||
bucket_id: Property.ShortText({
|
||||
displayName: 'Bucket ID',
|
||||
description: 'The ID of the bucket where the data is stored.',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run({ auth, propsValue }) {
|
||||
const { parser_id, bucket_id } = propsValue;
|
||||
|
||||
const response = await parserExpertCommon.apiCall<{
|
||||
data: Array<{
|
||||
parsed_data: Record<string, unknown>;
|
||||
parser_id: string;
|
||||
status: 'pending' | 'parsed' | 'error';
|
||||
updated_at: string;
|
||||
}>;
|
||||
message: string;
|
||||
}>({
|
||||
method: HttpMethod.GET,
|
||||
url: '/v1/extracts',
|
||||
auth: auth.secret_text,
|
||||
queryParams: {
|
||||
parser_id,
|
||||
bucket_id,
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { parserExpertAuth } from '../common/auth';
|
||||
import { parserExpertCommon } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
import FormData from 'form-data';
|
||||
|
||||
export const uploadDocument = createAction({
|
||||
auth: parserExpertAuth,
|
||||
name: 'upload_document',
|
||||
displayName: 'Upload Document',
|
||||
description: 'Upload a document or provide a webpage URL to parse. Supported formats: PDF, DOCX, Image, Txt File (maximum 10 pages per document).',
|
||||
props: {
|
||||
bucket_id: Property.ShortText({
|
||||
displayName: 'Bucket ID',
|
||||
description: 'The ID of the bucket where the data will be stored. You can find this in your dashboard under Manage Bucket.',
|
||||
required: true,
|
||||
}),
|
||||
file: Property.File({
|
||||
displayName: 'File',
|
||||
description: 'The file to upload. Supported formats: PDF, DOCX, Image, Txt File (maximum 10 pages per document). This will be ignored if webpage URL is provided.',
|
||||
required: false,
|
||||
}),
|
||||
webpage_url: Property.ShortText({
|
||||
displayName: 'Webpage URL',
|
||||
description: 'The URL of the webpage to extract content from. This will be ignored if file is provided.',
|
||||
required: false,
|
||||
}),
|
||||
},
|
||||
async run({ auth, propsValue }) {
|
||||
const { bucket_id, file, webpage_url } = propsValue;
|
||||
|
||||
if (!file && !webpage_url) {
|
||||
throw new Error('Either file or webpage URL must be provided');
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('bucket_id', bucket_id);
|
||||
|
||||
if (file) {
|
||||
formData.append('file', file.data, file.filename);
|
||||
} else if (webpage_url) {
|
||||
formData.append('webpage_url', webpage_url);
|
||||
}
|
||||
|
||||
const response = await parserExpertCommon.apiCall<{
|
||||
data: {
|
||||
parser_id: string;
|
||||
};
|
||||
message: string;
|
||||
}>({
|
||||
method: HttpMethod.POST,
|
||||
url: '/v1/upload',
|
||||
auth: auth.secret_text,
|
||||
body: formData,
|
||||
headers: formData.getHeaders(),
|
||||
});
|
||||
|
||||
return response;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { PieceAuth } from '@activepieces/pieces-framework';
|
||||
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
|
||||
|
||||
export const parserExpertAuth = PieceAuth.SecretText({
|
||||
displayName: 'API Key',
|
||||
description: 'Your Parser Expert API key. You can find this in your dashboard under Integration -> New API Key.',
|
||||
required: true,
|
||||
validate: async ({ auth }) => {
|
||||
if (!auth) {
|
||||
return {
|
||||
valid: false,
|
||||
error: 'API key is required',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
return {
|
||||
valid: true,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
valid: false,
|
||||
error: 'Invalid API key. Please check your API key and try again.',
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const parserExpertCommon = {
|
||||
baseUrl: 'https://api.parser.expert',
|
||||
|
||||
async apiCall<T>({
|
||||
method,
|
||||
url,
|
||||
auth,
|
||||
body,
|
||||
headers,
|
||||
queryParams,
|
||||
}: {
|
||||
method: HttpMethod;
|
||||
url: string;
|
||||
auth: string;
|
||||
body?: any;
|
||||
headers?: Record<string, string>;
|
||||
queryParams?: Record<string, string>;
|
||||
}): Promise<T> {
|
||||
let fullUrl = `${this.baseUrl}${url}`;
|
||||
|
||||
if (queryParams && Object.keys(queryParams).length > 0) {
|
||||
const params = new URLSearchParams(queryParams);
|
||||
fullUrl += `?${params.toString()}`;
|
||||
}
|
||||
|
||||
const response = await httpClient.sendRequest<T>({
|
||||
method,
|
||||
url: fullUrl,
|
||||
headers: {
|
||||
'X-API-Key': auth,
|
||||
...headers,
|
||||
},
|
||||
body,
|
||||
});
|
||||
|
||||
if (response.status >= 400) {
|
||||
throw new Error(`Parser Expert API error: ${response.status} ${JSON.stringify(response.body)}`);
|
||||
}
|
||||
|
||||
return response.body;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user