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,53 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { isString } from '@activepieces/shared';
|
||||
import {parse} from 'csv-parse/sync';
|
||||
|
||||
export const csvToJsonAction = createAction({
|
||||
name: 'convert_csv_to_json',
|
||||
displayName: 'Convert CSV to JSON',
|
||||
description:
|
||||
'This function reads a CSV string and converts it into JSON array format.',
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: {
|
||||
hide: true,
|
||||
},
|
||||
retryOnFailure: {
|
||||
hide: true,
|
||||
},
|
||||
},
|
||||
props: {
|
||||
csv_text: Property.LongText({
|
||||
displayName: 'CSV Text',
|
||||
defaultValue: '',
|
||||
required: true,
|
||||
}),
|
||||
has_headers: Property.Checkbox({
|
||||
displayName: 'Does the CSV have headers?',
|
||||
defaultValue: false,
|
||||
required: true,
|
||||
}),
|
||||
delimiter_type: Property.StaticDropdown({
|
||||
displayName: 'Delimiter Type',
|
||||
description: 'Select the delimiter type for the CSV text.',
|
||||
defaultValue: '',
|
||||
required: true,
|
||||
options: {
|
||||
options: [
|
||||
{ label: 'Comma', value: ',' },
|
||||
{ label: 'Tab', value: '\t' },
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { csv_text, has_headers, delimiter_type } = context.propsValue;
|
||||
if (!isString(csv_text)) {
|
||||
throw new Error(JSON.stringify({
|
||||
message: 'The input should be a string.',
|
||||
}))
|
||||
}
|
||||
|
||||
const records = parse(csv_text,{delimiter: delimiter_type,columns: has_headers ? true : false});
|
||||
return records;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { flatten } from 'safe-flat';
|
||||
import { stringify } from "csv-stringify/sync";
|
||||
|
||||
const markdown = `
|
||||
**Notes**:
|
||||
* The input should be a JSON array.
|
||||
* The JSON object will be flattened If nested and the keys will be used as headers.
|
||||
`
|
||||
export const jsonToCsvAction = createAction({
|
||||
name: 'convert_json_to_csv',
|
||||
displayName: 'Convert JSON to CSV',
|
||||
description: 'This function reads a JSON array and converts it into CSV format.',
|
||||
errorHandlingOptions: {
|
||||
continueOnFailure: { hide: true },
|
||||
retryOnFailure: { hide: true },
|
||||
},
|
||||
props: {
|
||||
markdown: Property.MarkDown({
|
||||
value: markdown,
|
||||
}),
|
||||
json_array: Property.Json({
|
||||
displayName: 'JSON Array',
|
||||
defaultValue: [
|
||||
{
|
||||
name: 'John',
|
||||
age: 30,
|
||||
address: {
|
||||
street: '123 Main St',
|
||||
city: 'Los Angeles',
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
age: 25,
|
||||
address: {
|
||||
street: '123 Main St',
|
||||
city: 'Los Angeles',
|
||||
}
|
||||
}
|
||||
],
|
||||
description:
|
||||
'Provide a JSON array to convert to CSV format.',
|
||||
required: true,
|
||||
}),
|
||||
delimiter_type: Property.StaticDropdown({
|
||||
displayName: 'Delimiter Type',
|
||||
description: 'Select the delimiter type for the CSV file.',
|
||||
defaultValue: ',',
|
||||
required: true,
|
||||
options: {
|
||||
options: [
|
||||
{ label: 'Comma', value: ',' },
|
||||
{ label: 'Tab', value: '\t' },
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { json_array, delimiter_type } = context.propsValue;
|
||||
if (!Array.isArray(json_array)) {
|
||||
throw new Error(JSON.stringify({
|
||||
message: 'The input should be a JSON array.',
|
||||
}))
|
||||
}
|
||||
const flattened = json_array.map((item) => flatten(item) as Record<string, string>);
|
||||
|
||||
return stringify(flattened, {
|
||||
header: true,
|
||||
delimiter: delimiter_type,
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user